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, Mistral, Google Gemini).

Installation

pip install simple-llm-api

Features

  • 🎯 Simple and consistent interface for multiple LLM providers
  • 🤖 Support for OpenAI, Mistral, and Google Gemini 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)

Mistral

from simple_llm_api import MistralAPI

mistral = MistralAPI("YOUR_API_KEY")
response = mistral.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)

Advanced Usage

Each API wrapper supports various parameters for fine-tuning the response:

OpenAI

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

Mistral

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

Gemini

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

Error Handling

The library includes custom exceptions for each API:

  • GeminiError: GeminiAPI Error
  • MistralError: MistralError Error
  • OpenAIError: OpenAIError Error

Requirements

  • requests

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.0.0.tar.gz (3.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.0.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for simple_llm_api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9e599910751f67a51292908c6c5660ed8c98ed214deee14490603c6c2033f69c
MD5 d36cdcf2d780c709a2fb92b3b0dc321a
BLAKE2b-256 bd6408ab1a5756d534ededc499b8ade4da2da16ce13b76a9b07dd80f09375c40

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for simple_llm_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd6c005242134a3e10cb254fcd28c34d287f1cc9b03b69e92a0a9cfaac6f1e1c
MD5 05b1b54fe95a294d42155c2ce58e75ff
BLAKE2b-256 24e7265c89aff879c506619ff36a351083ab429d603c398bd4a494b22ca606bc

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