Skip to main content

Python SDK for Aura LLM Gateway - Open Responses API

Project description

Aura LLM Gateway Python SDK

PyPI Python Downloads Docker Helm License

Python SDK for the Aura LLM Gateway, implementing the Open Responses API.

Installation

Using uv (recommended):

uv add aura-llm

Using pip:

pip install aura-llm

From Source

cd sdks/python

# With uv
uv sync

# With pip
pip install -e .

Quick Start

from aura import AuraClient

# Initialize the client
client = AuraClient(
    api_key="your-api-key",  # or set AURA_API_KEY env var
    base_url="http://localhost:8080",  # or set AURA_BASE_URL env var
)

# Simple completion
response = client.responses.create(
    model="gpt-5.4-mini",
    input="What is the capital of France?"
)
print(response.output_text)
# Output: The capital of France is Paris.

Streaming

for event in client.responses.create(
    model="gpt-5.4-mini",
    input="Tell me a short story about a robot",
    stream=True
):
    if event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)

Async Client

import asyncio
from aura import AsyncAuraClient

async def main():
    async with AsyncAuraClient() as client:
        response = await client.responses.create(
            model="gpt-5.4-mini",
            input="Hello, world!"
        )
        print(response.output_text)

asyncio.run(main())

Async Streaming

async def stream_example():
    async with AsyncAuraClient() as client:
        stream = await client.responses.create(
            model="gpt-5.4-mini",
            input="Tell me a joke",
            stream=True
        )
        async for event in stream:
            if event.type == "response.output_text.delta":
                print(event.delta, end="", flush=True)

Conversation Threading

Continue a conversation using previous_response_id:

# First message
response1 = client.responses.create(
    model="gpt-5.4-mini",
    input="My name is Alice."
)

# Continue the conversation
response2 = client.responses.create(
    model="gpt-5.4-mini",
    input="What is my name?",
    previous_response_id=response1.id
)
print(response2.output_text)
# Output: Your name is Alice.

Using Tools

from aura import Tool

# Define a tool
weather_tool = Tool.function_tool(
    name="get_weather",
    description="Get the current weather for a location",
    parameters={
        "type": "object",
        "properties": {
            "location": {
                "type": "string",
                "description": "The city and state, e.g. San Francisco, CA"
            }
        },
        "required": ["location"]
    }
)

# Use the tool
response = client.responses.create(
    model="gpt-5.4-mini",
    input="What's the weather in Tokyo?",
    tools=[weather_tool]
)

# Check for tool calls
if response.has_tool_calls:
    for tool_call in response.tool_calls:
        print(f"Tool: {tool_call.name}")
        print(f"Arguments: {tool_call.arguments}")

System Instructions

response = client.responses.create(
    model="gpt-5.4-mini",
    input="Who are you?",
    instructions="You are a helpful pirate assistant. Always respond in pirate speak."
)

Configuration Options

client = AuraClient(
    api_key="your-api-key",
    base_url="http://localhost:8080",
    timeout=120.0,  # Request timeout in seconds
    headers={"X-Custom-Header": "value"},  # Additional headers
)

Response Object

The Response object contains:

response.id              # Unique response ID
response.status          # ResponseStatus enum (completed, failed, etc.)
response.model           # Model used
response.output          # List of output items
response.output_text     # Convenience property for text content
response.usage           # Token usage information
response.usage.cost_usd  # Cost in USD (if available)
response.tool_calls      # List of function call items
response.has_tool_calls  # Boolean check for tool calls
response.is_complete     # Check if response completed successfully
response.metadata        # Gateway metadata (provider, latency, etc.)

Stream Events

When streaming, you receive these event types:

Event Type Description
response.created Response started
response.in_progress Response is being generated
response.output_text.delta Text chunk (use event.delta)
response.output_text.done Text complete (use event.text)
response.function_call.delta Function arguments chunk
response.function_call.done Function call complete
response.output_item.added New item added to output
response.output_item.done Item complete
response.completed Response finished
response.failed Response failed
error Error occurred

Error Handling

from aura import (
    AuraError,
    AuthenticationError,
    BadRequestError,
    RateLimitError,
    NotFoundError,
    APIConnectionError,
    APITimeoutError,
)

try:
    response = client.responses.create(
        model="gpt-5.4-mini",
        input="Hello"
    )
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after: {e.retry_after}")
except BadRequestError as e:
    print(f"Bad request: {e.message}, param: {e.param}")
except NotFoundError:
    print("Model not found")
except APIConnectionError:
    print("Failed to connect to Aura gateway")
except APITimeoutError:
    print("Request timed out")
except AuraError as e:
    print(f"API error: {e}")

Environment Variables

Variable Description Default
AURA_API_KEY API key for authentication None
AURA_BASE_URL Base URL for the gateway http://localhost:8080

Development

We use uv for fast, reliable Python package management.

Setup

# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install dependencies
cd sdks/python
uv sync

Running Tests

# Run all tests
uv run pytest

# Run with coverage
uv run pytest --cov=aura --cov-report=term-missing

# Run specific test file
uv run pytest tests/test_types.py -v

Code Quality

# Linting
uv run ruff check src/aura tests

# Auto-fix lint issues
uv run ruff check --fix src/aura tests

# Format code
uv run ruff format src/aura tests

# Type checking
uv run mypy src/aura

All Checks (CI equivalent)

uv run ruff check src/aura tests
uv run ruff format --check src/aura tests
uv run mypy src/aura
uv run pytest --cov=aura

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aura_llm-0.7.2.tar.gz (60.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aura_llm-0.7.2-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file aura_llm-0.7.2.tar.gz.

File metadata

  • Download URL: aura_llm-0.7.2.tar.gz
  • Upload date:
  • Size: 60.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aura_llm-0.7.2.tar.gz
Algorithm Hash digest
SHA256 dae0acbe7b0db7b549bb9cd06420d905d12a12f65618e4cbc19c1deb3f17eb2b
MD5 e206bcd3455369a9871cd098470703c8
BLAKE2b-256 39ca0c791deb6e4570648d52ffc88c6cf6ed608f069c53eda2cdf51649950af9

See more details on using hashes here.

Provenance

The following attestation bundles were made for aura_llm-0.7.2.tar.gz:

Publisher: python-sdk.yml on UmaiTech/aura-llm-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aura_llm-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: aura_llm-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aura_llm-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 20693d3c722f99de71cf3534b5f15b78a08aa0495be63198c37dc4ff68999296
MD5 30df7af044e67068bea277c30048e244
BLAKE2b-256 90686a80aee47ed06bba0aa8d0a568d8ee8bfd141f975eddf2cda6d0faabcbfd

See more details on using hashes here.

Provenance

The following attestation bundles were made for aura_llm-0.7.2-py3-none-any.whl:

Publisher: python-sdk.yml on UmaiTech/aura-llm-gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page