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

Using with LangChain

Install the SDK with the LangChain extra when you want to use Aura's OpenAI-compatible /v1 endpoint through ChatOpenAI:

uv add 'aura-llm[langchain]'

See examples/langchain_usage.py for a complete example covering basic chat, tool calling, and an LCEL chain.

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.15.0.tar.gz (62.0 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.15.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aura_llm-0.15.0.tar.gz
  • Upload date:
  • Size: 62.0 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.15.0.tar.gz
Algorithm Hash digest
SHA256 1e848fa9ebf7ba0867cb4fee30ba301c86ff876c6eab283be8532789af6a8e95
MD5 6a344a5a8633eac628aaef1968f8ffde
BLAKE2b-256 9696d2851cff3d10810f4a2d8cd6f487953815172fc5d7fd5d2fe6343eb1f59d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: aura_llm-0.15.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 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.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 859566523e444d7b0dd18f35eaecdfd9c2d72bccef1858f77684737113e597f0
MD5 347244b92909bc048ab20239cf2861d9
BLAKE2b-256 1a8670553bacb189dc24eb6b2025a9b3b99f1858bdd387f5119a54b934f3c583

See more details on using hashes here.

Provenance

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