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/sdk/server(Node)의 Python 대응이다. npm과 PyPI는 다른 레지스트리라 언어별로 분리 배포한다.

Install

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

Quick Start

from abto import create_abto

abto = create_abto(
    api_key="ABTO_API_KEY",
    gateway_base_url="https://gateway.abto.ai/v1",
)
openai = abto.openai()  # base_url=gateway + 요청마다 x-abto-* 주입

def generate(user_id: str, trace_id: str):
    with abto.with_context(user_id=user_id, node_id="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 abto_request_hook, with_context

client = httpx.Client(event_hooks={"request": [abto_request_hook()]})

with with_context(user_id="u1", node_id="resume.make"):
    client.post("https://gateway.abto.ai/v1/...")  # x-abto-* 자동 첨부

Public API

  • create_abto(api_key=None, gateway_base_url=None) -> Abto
  • abto.openai(**kwargs) — gateway baseURL + 헤더 주입된 OpenAI client (extra: openai)
  • abto.with_context(user_id=?, node_id=?, trace_id=?) — 요청 단위 context (context manager)
  • abto.get_headers(ctx=None) / abto.create_trace_id() / abto.httpx_event_hooks()
  • 하위 helper: with_context, get_context, set_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)

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.0.1.tar.gz (11.7 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.0.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: abto-0.0.1.tar.gz
  • Upload date:
  • Size: 11.7 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.0.1.tar.gz
Algorithm Hash digest
SHA256 82df3ecb519e58611c54f1bd4bc116f68829e0c20c40f53c066459ffd3bc1b06
MD5 e17ee9e722969657744c68149886201b
BLAKE2b-256 6f87d17ab721610506156fcb88b791f578196b15ced0f1f1cfcddc8ad0c67b17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: abto-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63bdc398be19816019c47653638d5f0fa447f22653df9b0da2477ed8340d0166
MD5 c496e019d9627cc3c46b749782a40dfb
BLAKE2b-256 4abb93779c7e0ded35df722653d8546a8f30856d2bf084d5dbc57a8e2832699c

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