LLMGateway Python SDK
A Python SDK for interacting with the LLMGateway API.
| Project | Status |
|---|---|
| CI | |
| Meta |
Installation
# using pip
pip install llmgateway-sdk
# using uv
uv pip install llmgateway-sdk
# using poetry
poetry add llmgateway-sdk
Usage
Basic Usage
from llmgateway import LLMGatewayClient, ChatCompletionRequest, Message
# Initialize the client
client = LLMGatewayClient(api_key="your-api-key")
# Create a chat completion request
request = ChatCompletionRequest(
model="gpt-4",
messages=[
Message(role="user", content="Hello!")
]
)
# Get a completion
response = client.chat_completions(request)
print(response.message)
# List available models
models = client.list_models()
for model in models.data:
print(f"Model: {model.name} (ID: {model.id})")
Async Usage
import asyncio
from llmgateway import LLMGatewayClient, ChatCompletionRequest, Message
async def main():
client = LLMGatewayClient(api_key="your-api-key")
request = ChatCompletionRequest(
model="gpt-4",
messages=[
Message(role="user", content="Hello!")
]
)
# Get a completion asynchronously
response = await client.achat_completions(request)
print(response.message)
# List models asynchronously
models = await client.alist_models()
for model in models.data:
print(f"Model: {model.name} (ID: {model.id})")
# Don't forget to close the client
await client.aclose()
asyncio.run(main())
Streaming Responses
from llmgateway import LLMGatewayClient, ChatCompletionRequest, Message
client = LLMGatewayClient(api_key="your-api-key")
request = ChatCompletionRequest(
model="gpt-4",
messages=[
Message(role="user", content="Tell me a story")
],
stream=True
)
# Get streaming responses
for response in client.chat_completions(request):
print(response.message, end="", flush=True)
Features
- Synchronous and asynchronous API support
- Streaming responses
- Type hints and validation using Pydantic
- Comprehensive test coverage
- Modern Python packaging with pyproject.toml
License
MIT License
Metadata
Release files for llmgateway-sdk 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llmgateway_sdk-0.1.1.tar.gz | 8.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llmgateway_sdk-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.6 kB
Release files / llmgateway_sdk-0.1.1.tar.gz
| Download URL | llmgateway_sdk-0.1.1.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
180786ac838be563a1d3607033fee98592c2d96f2aa3d37508ef65c7efa644cd
|
|
BLAKE2b-256 checksum How to use checksums |
8719c37730132a69deae2eaba95aea29efe1c0c54e2e63728d22e0b3b6a276cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2025.
Transparency logRelease files / llmgateway_sdk-0.1.1-py3-none-any.whl
| Download URL | llmgateway_sdk-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19308b96110e65ee946e70ecb984f39c031dc5a8f841aad1c921633f0e8aa369
|
|
BLAKE2b-256 checksum How to use checksums |
7215b47ad7827a1ccb32167215ecce78cae5ee78a9fe4af0f4e385ad8e116759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2025.
Transparency log