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.6.1.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.6.1-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aura_llm-0.6.1.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.6.1.tar.gz
Algorithm Hash digest
SHA256 30729c08e2e5bcaaff9a363c9e875cc476e5e0c17f4deaad12b6c32cf81f1f2b
MD5 2ab3963bd09f7f8ea66da67a7d898819
BLAKE2b-256 8426a8175bdac647a34a38154031399b0a2322d754fd3b61ebde487c0a1faa85

See more details on using hashes here.

Provenance

The following attestation bundles were made for aura_llm-0.6.1.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.6.1-py3-none-any.whl.

File metadata

  • Download URL: aura_llm-0.6.1-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.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa5e45475bfbcfbc97257ef04f84fe19374493e44286402529f198f8eebe07dd
MD5 5cc44da5527f275d6772739c4c99a5b8
BLAKE2b-256 96d8270f65cca1c76f99f358f9c238edc915e9e084ce311cabff1c31c78270f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for aura_llm-0.6.1-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