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.

Drop-in with the Official OpenAI SDK

You can also bypass the Aura SDK entirely and point the official openai Python package at Aura — just change the base_url:

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8080/v1",
    api_key="your-aura-api-key",
)
# use client.chat.completions.create(...) as usual

See examples/openai_sdk_compat.py for a complete runnable example with basic chat and streaming.

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.16.1.tar.gz (64.1 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.16.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aura_llm-0.16.1.tar.gz
  • Upload date:
  • Size: 64.1 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.16.1.tar.gz
Algorithm Hash digest
SHA256 311d9d867d1973d71caf22946068025defd370881b6f6942f004bccad85c340d
MD5 630145012c1637a4c93a405bc873f708
BLAKE2b-256 5324ff8ffb7e87221e4395b559fad2ff429d8add7a5c9753eab63f1a6537da3d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: aura_llm-0.16.1-py3-none-any.whl
  • Upload date:
  • Size: 17.9 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.16.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c2221fae75f13ca456a36280ceb0ee63b1928f1cf71e9d9f23163fcead0646a6
MD5 e5879e185806b4109d14ee6b899b6c5f
BLAKE2b-256 2ffbed124e291e2a390c558690840ff12ab63797b010a9e7fbf227f9d451b959

See more details on using hashes here.

Provenance

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