Skip to main content

A simple and easy-to-use LLM API Wrapper

Project description

Simple LLM API

A simple and easy-to-use Python wrapper for popular LLM APIs (OpenAI, Anthropic, and more).

Installation

pip install simple-llm-api

Features

  • 🎯 Simple and consistent interface for multiple LLM providers
  • 🤖 Support for OpenAI, Anthropic, Google Gemini, Mistral, and DeepSeek APIs
  • 🚀 Easy to use with minimal configuration
  • ⚙️ Customizable parameters for each provider

Quick Start

OpenAI

from simple_llm_api import OpenAIAPI

openai = OpenAIAPI("YOUR_API_KEY")
response = openai.simple_request("Hi!")
print(response)

Anthropic

from simple_llm_api import AnthropicAPI

anthropic = AnthropicAPI("YOUR_API_KEY")
response = anthropic.simple_request("Hi!")
print(response)

Google Gemini

from simple_llm_api import GeminiAPI

gemini = GeminiAPI("YOUR_API_KEY")
response = gemini.simple_request("Hi!")
print(response)

Mistral

from simple_llm_api import MistralAPI

mistral = MistralAPI("YOUR_API_KEY")
response = mistral.simple_request("Hi!")
print(response)

DeepSeek

from simple_llm_api import DeepSeekAPI

deepseek = DeepSeekAPI("YOUR_API_KEY")
response = deepseek.simple_request("Hi!")
print(response)

Easy Advanced Usage

Each API wrapper supports various parameters for customizing the response:

OpenAI

openai.simple_request(
    user_prompt="Your prompt here",
    system_prompt="Custom system prompt",
    temperature=1,
    top_p=1,
    max_completion_tokens=2048
)

Anthropic

anthropic.simple_request(
    user_prompt="Your prompt here",
    system_prompt="Custom system prompt",
    temperature=1,
    max_tokens=2048
)

Gemini

gemini.simple_request(
    user_prompt="Your prompt here",
    system_prompt="Custom system prompt",
    temperature=1,
    top_k=40,
    top_p=0.95,
    max_output_tokens=2048
)

Mistral

mistral.simple_request(
    user_prompt="Your prompt here",
    system_prompt="Custom system prompt",
    temperature=0.7,
    top_p=1,
    max_tokens=2048
)

DeepSeek

deepseek.simple_request(
    user_prompt="Your prompt here",
    system_prompt="Custom system prompt",
    temperature=1,
    top_p=1,
    max_tokens=2048
)

Error Handling

The library includes custom exceptions for each API:

  • OpenAIError: OpenAIAPI Error
  • AnthropicError: AnthropicAPI Error
  • GeminiError: GeminiAPI Error
  • MistralError: MistralAPI Error
  • DeepSeekError: DeepSeekAPI Error

Requirements

  • requests>=2.32.3

Disclaimer

This software is provided "as is" without any warranty. The authors are not responsible for any problems that may happen when you use this software.

This library connects to third-party LLM APIs (OpenAI, Anthropic, Google Gemini, Mistral, and DeepSeek). You must follow the rules of these APIs and manage any costs yourself.

You are responsible for how you use this software and what you do with it.

Using this software means you accept these terms.

License

This project is licensed under the MIT License.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_llm_api-1.2.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_llm_api-1.2.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file simple_llm_api-1.2.1.tar.gz.

File metadata

  • Download URL: simple_llm_api-1.2.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for simple_llm_api-1.2.1.tar.gz
Algorithm Hash digest
SHA256 7b5c8fd7576489e8aa7a06b814afb1fc1be8a19e9f09bee8a2bb0dd8d27fe063
MD5 d558ae48e035ee67ae04e4c538bc44e3
BLAKE2b-256 b9e171bf534cf8cbe67a0f0993e9972cfc60f2b04dde71ab2ca047fd090b5af2

See more details on using hashes here.

File details

Details for the file simple_llm_api-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: simple_llm_api-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for simple_llm_api-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d28814dd4a65a54d56db9453c079a1578152da2cbbc0138db8fd822fe52d824
MD5 cf55acacc2ebded6908036910f2eb2df
BLAKE2b-256 c0b7932a01bd6e41bf6ea73f816fddcd8a3dffa4af73f58eb97f385cfcd70862

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page