Everstack Python SDK
The official Python SDK for the Everstack AI platform. Requires Python 3.9 or later. Uses HTTP with httpx and Pydantic v2 response models.
Installation
pip install everstack
Configuration
Set your gateway instance URL and API key before running the examples:
export EVERSTACK_BASE_URL="https://<instance>.<region>.everstack.ai"
export EVERSTACK_API_KEY="your-api-key"
from everstack import Everstack
client = Everstack() # Reads the environment variables above.
# Or pass explicit values, with api_key as the first positional argument:
client.close()
client = Everstack("your-api-key", base_url="http://localhost:8089")
client.close()
Both Everstack and AsyncEverstack resolve base_url in this order:
explicit base_url, EVERSTACK_BASE_URL, then EVERSTACK_GATEWAY_URL.
Trailing slashes and one trailing /openai/v1 or /v1 are removed.
There is no default gateway URL. Without a configured URL, construction raises
ValueError with this message:
everstack: no base URL configured. Pass base_url or set EVERSTACK_BASE_URL to your gateway URL, e.g. https://<instance>.<region>.everstack.ai
The API key resolves from the explicit api_key or EVERSTACK_API_KEY and is
sent as x-evs-api-key. An empty key is allowed, for example when using
Everstack(base_url="https://example.test", access_token="user-access-token")
for OpenAI Agents. access_token adds an Authorization Bearer header.
Optional constructor settings are provider, org_id, user_id, headers,
and timeout (seconds, default 60). Use with or async with, or call
close() (await it for the async client), to release HTTP connections.
Synchronous chat
from everstack import Everstack
with Everstack() as client:
response = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
for chunk in client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "Tell me a short joke"}],
stream=True,
):
for choice in chunk.choices:
print(choice.delta.content or "", end="", flush=True)
Chat calls use /openai/v1/chat/completions. Streaming accepts SSE or JSON
lines. If the gateway returns a single completion when SSE is disabled, the
SDK yields it as one ChatCompletionChunk.
Asynchronous chat
import asyncio
from everstack import AsyncEverstack
async def main():
async with AsyncEverstack() as client:
response = await client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
stream = await client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "Tell me a short joke"}],
stream=True,
)
async for chunk in stream:
for choice in chunk.choices:
print(choice.delta.content or "", end="", flush=True)
asyncio.run(main())
Embeddings and models
from everstack import Everstack
with Everstack() as client:
embeddings = client.embeddings.create(
model="text-embedding-3-small", input="Hello world",
)
print(embeddings.data[0].embedding)
models = client.models.list()
for model in models.data:
print(model.id, model.owned_by)
These calls use /openai/v1/embeddings and /openai/v1/models and return
EmbeddingsResponse and ModelsListResponse. Access fields as attributes,
or use .model_dump() for a dictionary. With AsyncEverstack, await
client.embeddings.create(...) and client.models.list().
Responses
from everstack import Everstack
with Everstack() as client:
response = client.responses.create(
model="gpt-5.5",
input=[{"role": "user", "content": "Hello!"}],
)
print(response.id, response.status)
for item in response.output:
print(item.content)
Non-streaming creation uses /v1/responses and returns a ResponseObject
from the final snapshot in the gateway's NDJSON response. A single JSON object
also works. Errors in any frame raise APIError, and an empty stream raises
APIError("empty response stream", status_code=200).
responses.get(response_id), cancel(response_id), delete(response_id) and
list(limit=10) are also available. Await the same calls on AsyncEverstack.
For async streaming, await client.responses.create(..., stream=True) and
iterate the returned stream with async for.
Streaming responses
client.responses.create(..., stream=True) yields the gateway's stream
frames as dicts, each wrapped as {"result": {...}}:
- a snapshot of the whole response (
status: "in_progress"and the fulloutput) whenever its structure changes: a new output item or content part; - a delta frame, with no
statusand nooutput, carrying only what one item grew by.result.delta.item_idnames the item, andresult.delta.content_delta(message text) orresult.delta.arguments_delta(function call arguments) is the fragment to append.output_indexandcontent_indexlocate the item and its content part; like every zero-valued field they are omitted when 0; - the final, full response (
status: "completed","failed"or"incomplete").
To rebuild the output as it arrives, replace each item with a snapshot's version and append each delta's fragment:
items = {}
for frame in client.responses.create(model="gpt-5.5", input=[...], stream=True):
res = frame.get("result", {})
delta = res.get("delta")
if delta:
item = items.setdefault(delta["item_id"], {"text": "", "arguments": ""})
item["text"] += delta.get("content_delta", "")
item["arguments"] += delta.get("arguments_delta", "")
continue
for out in res.get("output", []):
text = "".join(p.get("text", "") for p in out.get("content", []))
items[out["id"]] = {"text": text, "arguments": out.get("arguments", "")}
Errors
from everstack import APIError, Everstack, RateLimitError
with Everstack() as client:
try:
client.models.list()
except RateLimitError as error:
print(error.message, error.retry_after)
except APIError as error:
print(error.status_code, error.code, error.message)
All SDK errors inherit from EverstackError. HTTP API errors expose
status_code, code, param, and message. HTTP status mapping:
| Status | Exception |
|---|---|
| 401 | AuthenticationError |
| 403 | PermissionDeniedError |
| 404 | NotFoundError |
| 429 | RateLimitError |
| 500 | InternalServerError |
| 503 | ServiceUnavailableError |
| Other HTTP errors | APIError |
RateLimitError.retry_after is a float in seconds when a numeric Retry-After
header is present, otherwise None. Errors inside successful response frames
raise APIError. Network timeouts raise everstack.TimeoutError, and
connection failures raise everstack.ConnectionError. InvalidModelError
is also exported for model validation errors.
Client resources
Both clients expose these resources. Several management resources have different sync and async method layouts; the examples below show the existing sync API.
| Resource | Synchronous API examples |
|---|---|
chat |
chat.completions.create(...) |
embeddings |
embeddings.create(...) |
models |
models.list() |
audio |
audio.transcriptions.create(...), audio.translations.create(...), audio.speech.create(...) |
images |
images.generate(...), images.edit(...), images.create_variation(...) |
moderations |
moderations.create(...) |
decisions |
decisions.create(...) |
rerank |
rerank.create(...) |
responses |
responses.create(...), get(...), cancel(...), delete(...), list(...) |
agents |
agents.create(...), agents.sessions.run_turn(session_id, user_input="Hello"), agents.memories.list(agent_id) |
datasets |
datasets.create(...), datasets.items.create_batch(...) |
evaluations |
evaluations.runs.create(...), evaluations.schedules.create(...), evaluations.score(...) |
observability |
observability.metrics.get_dashboard(...), observability.sessions.list(...) |
traces |
traces.get(trace_id=...), traces.span(...), traces.capture_exception(...) |
openai_agents |
openai_agents.connections.create(...), openai_agents.sessions.create(...) |
For example, async agent management uses await client.agents.create_session(...)
and await client.agents.run_turn(session_id, user_input="Hello");
async observability uses await client.observability.get_metrics_dashboard(...).
client.capture_exception(...) and client.capture_message(...) delegate to
traces (await these on the async client). Most management calls return plain
dictionaries; chat, embeddings, models and Responses return Pydantic models.
The package also exports everstack.evals helpers for pytest evaluation gating
and generated model aliases under everstack.generated.models.
Examples and development
The examples/ directory contains sync chat, async chat, agents, Responses,
evaluation gating and a live gateway smoke script. All use environment-based
configuration. Run python scripts/check_examples.py to check syntax, imports,
client construction and resource attribute chains without making gateway calls.
pytest -q tests
ruff check src/
mypy src/everstack/ --ignore-missing-imports
python scripts/generate_models.py
Documentation
Metadata
Release files for everstack 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| everstack-0.2.0.tar.gz | 79.3 kB | With provenance | Details for everstack-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| everstack-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for everstack-0.2.0-py3-none-any.whl |
Total release size: 149.7 kB
Release files / everstack-0.2.0.tar.gz
| Download URL | everstack-0.2.0.tar.gz |
|---|---|
| Size | 79.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
838e208b593f91e936de432473e4a01b9e58cc8c75db31d0698248a35ba31452
|
|
BLAKE2b-256 checksum How to use checksums |
9413834d0d752d64f2bac54953da092fb74e357b67f9084ecbc5146dbaa063bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logRelease files / everstack-0.2.0-py3-none-any.whl
| Download URL | everstack-0.2.0-py3-none-any.whl |
|---|---|
| Size | 70.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d902f4442ab08325a3c1c61837f83a2be2e17f2caaf133161f8deab18c49652
|
|
BLAKE2b-256 checksum How to use checksums |
091c080e496ab74f9ce1b84db0b750d1ffce8db3431ab1b1206e908eebd16a07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logSecurity for everstack 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for everstack-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.