Skip to main content

LLM API for python

This python library connects to llm-api using python, it was build to mimic OpenAI's python library

Usage

You can install this library using pip

pip install llm-api-python

After running llm-api, simply configure your client as if it's OpenAI's python binding

import llm_api

llm_api.api_key = "<your llm-api api key here>"

completion = llm_api.ChatCompletion.create(messages=[
    {
        "role": "system", 
        "content": "You are a helpful assistant, please answer the users' questions with honesty and accuracy."
    }, {
        "role": "user", "content": "What is the capital of France?"
    }
])  # returns a chat completion object

completion = llm_api.ChatCompletion.create(messages=[
    ...
], stream=True) # returns a generator

completion = await llm_api.ChatCompletion.acreate(messages=[
    ...
]) # returns a chat completion object

completion = await llm_api.ChatCompletion.acreate(messages=[
    ...
], stream=True) # returns a async generator

Limitations

  • request_id and request_ms are currently returned empty
  • created timestamp is not set by the server
  • finish_reason is hardcoded to stop
  • usage values are set to None
  • the model attribute is not being used

Credit

OpenAI's python implementation since this implementation is technically a fork of it.

Metadata

Release files for llm-api-python 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-api-python 0.0.2
File Size Uploaded Provenance
llm_api_python-0.0.2.tar.gz 10.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-api-python 0.0.2
File Interpreter ABI Platform
llm_api_python-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / llm_api_python-0.0.2.tar.gz

Download URL llm_api_python-0.0.2.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8f245d3254489016a4723b66819e59d0de971f7c18737204e03a8e3402c87c18
BLAKE2b-256 checksum
How to use checksums
efe65644d651e1f36b5519b047988fdb5e44fcdaec4917bfde99e7c60676ad81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.8.18 Linux/6.2.0-1014-azure

Release files / llm_api_python-0.0.2-py3-none-any.whl

Download URL llm_api_python-0.0.2-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aaee9fea7feb5060d0cf197f64ea2e68c3fc9930843e1fbf3f1b4e37c9a1c944
BLAKE2b-256 checksum
How to use checksums
e0ecc854dce88fb34d273e7e6fe5868229a55153addc1c2b010fb9a01d476a0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.8.18 Linux/6.2.0-1014-azure

Security for llm-api-python 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page