Skip to main content

Octpo Python SDK

octpo is the Python client for Octpo's hosted API at https://platform-octpo.vercel.app/v1. It uses HTTPX and supports synchronous and asynchronous calls.

Installation

python -m pip install octpo

For a local checkout:

cd octpo_python_lib
python -m venv .venv
. .venv/bin/activate  # Windows: .venv\Scripts\activate
python -m pip install -e '.[test]'

Quick start

Set OCTPO_API_KEY to the caller bearer token configured for your Octpo deployment:

export OCTPO_API_KEY="your-token"
import octpo

client = octpo.Client(
    default_headers={"X-Client-Name": "Octpo", "X-Client-Version": "1.0.0"},
)
response = client.responses.create(model="octpo-auto", input="Hello! Introduce yourself briefly.")
print(response.output_text)
client.close()

The equivalent async call is:

import asyncio
import octpo

async def main():
    async with octpo.AsyncClient() as client:
        response = await client.responses.create(model="octpo-auto", input="Hello!")
        print(response.output_text)

asyncio.run(main())

Configuration

Both clients accept api_key, base_url, default_headers, timeout (seconds or httpx.Timeout), max_retries (default 2), and an optional HTTPX client as http_client. If api_key is omitted, the client reads OCTPO_API_KEY. Authorization is always set to the supplied API key; custom headers cannot replace Authorization, Accept, or Content-Type. Requests use Authorization: Bearer ….

Retries are limited to idempotent model discovery (GET /models) for transport failures, timeouts, 429, and selected transient 5xx responses. Retry-After is honored up to 30 seconds. Response creation is never automatically retried because it is a non-idempotent POST.

Supported API

The SDK matches the Vercel gateway implementation:

  • POST /responses: text-only input, model, instructions, max_output_tokens, temperature, top_p, and metadata. Returns a typed Response with output_text.
  • GET /models: lists public model IDs configured for the deployment. IDs can vary by deployment; source defaults are octpo-auto and octpo-code.
  • POST /chat/completions is implemented by the gateway, but is not exposed in this first SDK release; use the Responses API for supported text generation.

The Responses gateway does not support image/audio inputs, tool calling, or streaming. It rejects unsupported request fields instead of silently ignoring them. Streaming is not implemented in this SDK. The gateway has no documented OpenAPI schema or additional endpoints in its route configuration; /health, action, and computer-use routes are not part of this hosted gateway.

Errors

All SDK exceptions derive from OctpoError. HTTP errors derive from APIError and expose status_code, response, and body. Common status codes map to AuthenticationError, InvalidRequestError, RateLimitError, and ServerError. Connection failures raise NetworkError; timeouts raise APITimeoutError; incompatible successful payloads raise ResponseFormatError. API error messages are retained.

Troubleshooting

  • 503 API is not configured: the deployment has not configured its caller token.
  • 401 invalid/missing API token: verify OCTPO_API_KEY matches the deployment's OCTPO_API_TOKEN. Never include it in source control or logs.
  • 400 unsupported fields: this gateway accepts only the fields listed above and text message input. Remove unsupported options.
  • 502/504 upstream errors: the hosted gateway could not obtain a valid response from the configured Octpo model server; check the deployment's upstream configuration.

Local checks

python -m pytest
python -m ruff check src tests
python -m mypy src
python -m build

Integration tests run only when OCTPO_API_KEY is explicitly set. They do not print the key.

Metadata

Release files for octpo 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for octpo 0.1.0
File Size Uploaded
octpo-0.1.0.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for octpo 0.1.0
File Interpreter ABI Platform
octpo-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / octpo-0.1.0.tar.gz

Download URL octpo-0.1.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d9ae26e4eb3d4c6456280e28997209dff0821636fc64ef8bfb05e943a1dfc47a
BLAKE2b-256 checksum
How to use checksums
4730c73d835a450143ae310b88a661e850f87096a9a1fd8ab363724cce800be3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / octpo-0.1.0-py3-none-any.whl

Download URL octpo-0.1.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1294bdd21808670c2a609d62e3e72de19a814397350e48857cc0cbfab739f592
BLAKE2b-256 checksum
How to use checksums
f913bc1ccbd136e14d2e0ab394793e3359efa204d7bed47f275bc1d6d5656f76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page