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.1.tar.gz (16.8 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.1-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: abto-0.1.1.tar.gz
  • Upload date:
  • Size: 16.8 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.1.tar.gz
Algorithm Hash digest
SHA256 b08694075eb97435c0eeee010270f5d6593213880c070d3d285228f30a69cdff
MD5 51dfbc4c07c59ef2cde8764dad819f56
BLAKE2b-256 22cb7ff98b80d9f64b11ab59780565639d4a8138d458764e8c4f9a5730a37e14

See more details on using hashes here.

File details

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

File metadata

  • Download URL: abto-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0539a7c5a96a57cf865a6668a15680b624d4ba865432e37ed2c8bb489dda51df
MD5 db17cbcf2b229d191bf4abecd899c1dd
BLAKE2b-256 270c12386441b03143f0cd9db0cd78d23b013ea217ee4d886ac0fee5783490aa

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