Skip to main content

abto (Python)

ABTO server-side SDK for Python. 얇은 gateway 헤더 helper로, contextvarsx-abto-* 식별자를 운반하고 httpx event hook으로 outbound provider 호출에 주입한다. token·cost·latency·request_id·variant는 gateway가 소유한다.

@abto-app/calling(Node)의 Python 대응이다. npm과 PyPI는 다른 레지스트리라 언어별로 분리 배포한다.

Install

pip install abto                 # 코어(contextvars 헤더 helper)
pip install "abto[openai]"       # openai + httpx 통합까지

Quick Start

import os

from abto import init_abto

abto = init_abto(
    api_key=os.environ["ABTO_API_KEY"],
    gateway_base_url="https://gateway.abto.app/v1",
    provider_keys={
        "openai": os.environ["OPENAI_API_KEY"],
        # 프로젝트가 Anthropic/Gemini로 라우팅될 수 있으면 해당 후보 키도 함께 전달한다.
        # "anthropic": os.environ["ANTHROPIC_API_KEY"],
        # "gemini": os.environ["GEMINI_API_KEY"],
    },
)
openai = abto.openai()  # Gateway 인증·context·provider 후보 키를 요청마다 주입

def generate(device_id: str, trace_id: str):
    with abto.with_context(device_id=device_id, node_key="resume.make", trace_id=trace_id):
        return openai.chat.completions.create(
            model="gpt-4.1",
            messages=[{"role": "user", "content": "Create a resume draft"}],
        )

httpx 직접 사용

import httpx
from abto import with_context

client = httpx.Client(event_hooks=abto.httpx_event_hooks())

with with_context(device_id="d1", node_key="resume.make"):
    client.post("https://gateway.abto.app/v1/...")  # x-abto-* 자동 첨부

Public API

  • init_abto(api_key=None, gateway_base_url=None, provider_keys=None) -> Abto — ABTO inbound key와 provider 후보 키를 구성
  • abto.openai(**kwargs) — gateway baseURL + 헤더 주입된 OpenAI client (extra: openai)
  • abto.with_context(device_id=?, node_key=?, trace_id=?) — 요청 단위 context (context manager)
  • abto.get_headers(ctx=None) / abto.create_trace_id() / abto.httpx_event_hooks()
  • 하위 helper: with_context, get_context, get_headers, create_trace_id, create_traceparent, abto_request_hook, ABTO_HEADER, AbtoContext

Header Contract

x-abto-device-id     (required)
x-abto-node-key     (required; "feature.node" dot notation, e.g. resume.make)
traceparent        (trace_id; gateway-deferred in Round1)
x-abto-key-openai  (route 후보 provider key; provider별로 선택해 추가)
Authorization       (required; Bearer ABTO inbound key)

Gateway는 API key를 tenant_id로 매핑하고 request_id(응답 x-request-id)를 발급하며 variant_id를 배정하고, provider 전달 전 x-abto-*를 strip한다.

Test

pip install pytest && pytest

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

abto-0.1.0.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

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

abto-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file abto-0.1.0.tar.gz.

File metadata

  • Download URL: abto-0.1.0.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Amazon Linux","version":"2023","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for abto-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5fd63d32b3226b4aaca7daba5daed27159eae2c5066c668851c1948db6460f7f
MD5 3becda395e63f78363968dee03c0e8bd
BLAKE2b-256 d4023a373bca98e5b871881e364920c5821a492efa0bfd14322641bfe7d1b425

See more details on using hashes here.

File details

Details for the file abto-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: abto-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Amazon Linux","version":"2023","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for abto-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2e85b440c96ec8ddd4f030214ec103d440757e9a05b6ce0973ebacfc3cee450
MD5 6e10ec029f35a638473ead81da236f3d
BLAKE2b-256 20a08ce36dcc29039bdcb8ccfbb0a1f07f9668dda2d8555add3839f0a718ca49

See more details on using hashes here.

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