Lightweight, type-safe Python SDK for the Edgee AI Gateway.
pip install edgeefrom edgee import Edgee
edgee = Edgee("your-api-key")
# Send a simple request
response = edgee.send(
model="gpt-4o",
input="What is the capital of France?"
)
print(response.text)
# "The capital of France is Paris."The send() method makes non-streaming chat completion requests:
response = edgee.send(
model="gpt-4o",
input="Hello, world!"
)
# Access response
print(response.text) # Text content
print(response.finish_reason) # Finish reason
print(response.tool_calls) # Tool calls (if any)
# Access usage and compression info
if response.usage:
print(f"Tokens used: {response.usage.total_tokens}")
if response.compression:
print(f"Input tokens: {response.compression.input_tokens}")
print(f"Saved tokens: {response.compression.saved_tokens}")
print(f"Compression rate: {response.compression.rate}")The stream() method enables real-time streaming responses:
for chunk in edgee.stream("gpt-4o", "Tell me a story"):
if chunk.text:
print(chunk.text, end="", flush=True)
if chunk.finish_reason:
print(f"\nFinished: {chunk.finish_reason}")- ✅ Type-safe - Full type hints with dataclasses
- ✅ OpenAI-compatible - Works with any model supported by Edgee
- ✅ Streaming - Real-time response streaming with generators
- ✅ Tool calling - Full support for function calling
- ✅ Flexible input - Accept strings, dicts, or InputObject
- ✅ Compression info - Access token compression metrics in responses
- ✅ Zero dependencies - Uses only Python standard library
For complete documentation, examples, and API reference, visit:
👉 Official Python SDK Documentation
The documentation includes:
- Configuration guide - Multiple ways to configure the SDK
- Send method - Complete guide to non-streaming requests
- Stream method - Streaming responses guide
- Tools - Function calling guide
Licensed under the Apache License, Version 2.0. See LICENSE for details.