infinity-llm: Use any LLM API
infinity-llm is a collection of Python tools to make LLM APIs plug-and-play for fast, easy experimentation. I use this in my own projects today, but it's still very much a work in progress. I'm trying to strike the balance between simplicity and modularity, so if you have ideas feel free to message me or submit a PR!
Key Features
- Chat Completion: Mostly a wrapper around jxnl/instructor, supports a/sync chat completion and streaming for structured and unstructured chat completions.
- Embeddings/Rerankers: Easily use a slew of embedding and reranking models
- Asynchronous Workloads: Run all chat completion and embedding workloads in massively parallel fashion without worrying about rate limits. Nice for ETL pipelines.
- OpenAI Batch Jobs: Run large scale batch jobs with OpenAI's batch API.
Chat Completion
All types of chat completions are made easy!
- Make a client
from infinity_llm import from_any, Provider
client = from_any(
provider=Provider.OPENAI,
model_name="gpt-4o",
async_client=False
)
- Choose between a/sync un/structured response with/without streaming
# synchronous, unstructured response without streaming
# (aka a standard chat completion
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a friend."},
{"role": "user", "content": "Tell me about your day."}
],
response_model=None # No response model means unstructured response
)
Embeddings/Rerankers
from infinity_llm import Provider, embed_from_any
# Create a Cohere embedding client
client = embed_from_any(Provider.COHERE)
# Example text to embed
text = "This is an example sentence to embed using Cohere."
# Get the embedding
embeddings, total_tokens = client.create(input=text, model="embed-english-v3.0", input_type="clustering")
print(f"Number of embeddings: {len(embeddings)}")
# > Number of embeddings: 1
print(f"Embedding dimension: {len(embeddings[0])}")
# > Embedding dimension: 1536
print(f"Usage: {total_tokens}")
# > Usage: 13
Metadata
Release files for infinity-llm 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| infinity_llm-0.1.0.tar.gz | 20.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| infinity_llm-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.9 kB
Release files / infinity_llm-0.1.0.tar.gz
| Download URL | infinity_llm-0.1.0.tar.gz |
|---|---|
| Size | 20.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
560f920298c775b63bb422706f5f4d970185ebb874878688927d4af07fed8bc0
|
|
BLAKE2b-256 checksum How to use checksums |
f4d18ba3ca076e512324e662de6927938740f2a85c9f41d2f2b90ae2f66fa88f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.4
|
Release files / infinity_llm-0.1.0-py3-none-any.whl
| Download URL | infinity_llm-0.1.0-py3-none-any.whl |
|---|---|
| Size | 28.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c75616ed42b244098e1f59c3bbb171bf221465c5e8de1efb97a6e3eaeebbeabc
|
|
BLAKE2b-256 checksum How to use checksums |
9a7e8c3020ef32ff9f2a56dc3d9ce3069b700ebfee7b6852b83004524f967005
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.4
|
Security for infinity-llm 0.1.0
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.