LLMGateway Python SDK Client
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llmgateway_sdk-0.1.1.tar.gz.
File metadata
- Download URL: llmgateway_sdk-0.1.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
180786ac838be563a1d3607033fee98592c2d96f2aa3d37508ef65c7efa644cd
|
|
| MD5 |
a2cf24a38e32e97e8dd197ac7f2b9c9b
|
|
| BLAKE2b-256 |
8719c37730132a69deae2eaba95aea29efe1c0c54e2e63728d22e0b3b6a276cc
|
Provenance
The following attestation bundles were made for llmgateway_sdk-0.1.1.tar.gz:
Publisher:
release.yaml on yezz123/llmgateway-py-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmgateway_sdk-0.1.1.tar.gz -
Subject digest:
180786ac838be563a1d3607033fee98592c2d96f2aa3d37508ef65c7efa644cd - Sigstore transparency entry: 234460198
- Sigstore integration time:
-
Permalink:
yezz123/llmgateway-py-sdk@c25442faa34f8746a0bfbd4e15b4d6bf217c51c9 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/yezz123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@c25442faa34f8746a0bfbd4e15b4d6bf217c51c9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file llmgateway_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: llmgateway_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19308b96110e65ee946e70ecb984f39c031dc5a8f841aad1c921633f0e8aa369
|
|
| MD5 |
7f72c3d1fcc4bddada11d6e2edcc4f43
|
|
| BLAKE2b-256 |
7215b47ad7827a1ccb32167215ecce78cae5ee78a9fe4af0f4e385ad8e116759
|
Provenance
The following attestation bundles were made for llmgateway_sdk-0.1.1-py3-none-any.whl:
Publisher:
release.yaml on yezz123/llmgateway-py-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmgateway_sdk-0.1.1-py3-none-any.whl -
Subject digest:
19308b96110e65ee946e70ecb984f39c031dc5a8f841aad1c921633f0e8aa369 - Sigstore transparency entry: 234460206
- Sigstore integration time:
-
Permalink:
yezz123/llmgateway-py-sdk@c25442faa34f8746a0bfbd4e15b4d6bf217c51c9 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/yezz123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@c25442faa34f8746a0bfbd4e15b4d6bf217c51c9 -
Trigger Event:
release
-
Statement type: