Skip to main content

Anthropic Claude transport for Axio (direct API and Vertex AI)

Project description

axio-transport-anthropic

PyPI Python License: MIT

Anthropic Claude transport for axio.

Streams Claude responses over the Anthropic Messages API using aiohttp and SSE parsing. Supports direct API, Vertex AI, prompt caching, extended thinking, and automatic retry on rate-limit and overload errors.

Features

  • All Claude models — Opus, Sonnet, Haiku; configurable via ANTHROPIC_MODELS
  • Vertex AI — use Claude via Google Cloud with ADC authentication
  • Prompt cachingcache_control: ephemeral applied automatically to the system prompt and the last tool definition
  • Extended thinkingReasoningDelta events emitted for thinking blocks
  • Retry logic — automatic backoff on 429 / 529; honours Retry-After header
  • TUI integration — settings screen for API key and model selection

Installation

pip install axio-transport-anthropic

With the TUI settings screen:

pip install "axio-transport-anthropic[tui]"

With Vertex AI support:

pip install "axio-transport-anthropic[vertexai]"

Usage

import asyncio
import aiohttp
from axio import Agent
from axio.context import MemoryContextStore
from axio_transport_anthropic import AnthropicTransport, ANTHROPIC_MODELS

async def main() -> None:
    async with aiohttp.ClientSession() as session:
        transport = AnthropicTransport(
            api_key="sk-ant-...",
            model=ANTHROPIC_MODELS["claude-sonnet-4-6"],
            session=session,
        )
        agent = Agent(system="You are helpful.", tools=[], transport=transport)
        ctx = MemoryContextStore()
        print(await agent.run("Hello!", ctx))

asyncio.run(main())

Set the API key via environment variable instead of passing it directly:

export ANTHROPIC_API_KEY="sk-ant-..."

Vertex AI

transport = AnthropicTransport(
    vertexai=True,
    project="my-gcp-project",
    location="us-east5",
    session=session,
)
# Uses Application Default Credentials (gcloud auth application-default login)

Models

Model ID Context Max output Notes
claude-opus-4-6 1 M 128 k Most capable
claude-sonnet-4-6 1 M 64 k Balanced (default)
claude-haiku-4-5-20251001 200 k 64 k Fastest / cheapest
claude-opus-4-5 200 k 64 k
claude-sonnet-4-5 200 k 64 k

Configuration

Parameter Default Description
api_key "" Anthropic API key
model claude-sonnet-4-6 Active model
base_url https://api.anthropic.com/v1 API base URL
vertexai False Use Vertex AI backend
project "" GCP project ID (Vertex AI)
location "" GCP region, e.g. us-east5 (Vertex AI)
max_retries 10 Max retry attempts on 429/529
retry_base_delay 5.0 Base delay (seconds) for exponential backoff

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

axio_transport_anthropic-0.9.6.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

axio_transport_anthropic-0.9.6-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file axio_transport_anthropic-0.9.6.tar.gz.

File metadata

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

File hashes

Hashes for axio_transport_anthropic-0.9.6.tar.gz
Algorithm Hash digest
SHA256 eae520fe767f62e2894481ea1260b4f2ebf9aaba160ad7656f559bc196688a43
MD5 94769ebce92d263de85c6ae3da31e6d9
BLAKE2b-256 58ac9049885e858a7796a6fe932f63a17390cd87e463c04d32b0110750c2d86b

See more details on using hashes here.

Provenance

The following attestation bundles were made for axio_transport_anthropic-0.9.6.tar.gz:

Publisher: publish.yml on mosquito/axio-agent

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

File details

Details for the file axio_transport_anthropic-0.9.6-py3-none-any.whl.

File metadata

File hashes

Hashes for axio_transport_anthropic-0.9.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f432c4bfbb55e55e1b0c2a24b342cc5f9c19e9958d0fea57e5beaabc1676aae2
MD5 89079042362f5be1280188b456904f0d
BLAKE2b-256 05254420e0117403bae664c2ce54545c7f11fbf7b4fcd76f28921f20e5f489be

See more details on using hashes here.

Provenance

The following attestation bundles were made for axio_transport_anthropic-0.9.6-py3-none-any.whl:

Publisher: publish.yml on mosquito/axio-agent

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