everstack 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {everstack-0.1.0 → everstack-0.2.0}/.gitignore +10 -0
- everstack-0.2.0/PKG-INFO +290 -0
- everstack-0.2.0/README.md +259 -0
- everstack-0.2.0/examples/agents_basic.py +32 -0
- {everstack-0.1.0 → everstack-0.2.0}/examples/async_client.py +5 -4
- everstack-0.2.0/examples/chat_basic.py +28 -0
- everstack-0.2.0/examples/evals_pytest.py +56 -0
- everstack-0.2.0/examples/responses_api.py +38 -0
- {everstack-0.1.0 → everstack-0.2.0}/examples/test_all.py +6 -15
- {everstack-0.1.0 → everstack-0.2.0}/pyproject.toml +1 -1
- everstack-0.2.0/scripts/check_examples.py +52 -0
- everstack-0.2.0/scripts/generate_models.py +293 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/__init__.py +39 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/_client.py +75 -23
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/_errors.py +30 -15
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/_transport.py +136 -71
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/_types.py +15 -1
- everstack-0.2.0/src/everstack/_version.py +1 -0
- everstack-0.2.0/src/everstack/evals.py +204 -0
- everstack-0.2.0/src/everstack/generated/models.py +10231 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/agents.py +128 -3
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/chat.py +7 -5
- everstack-0.2.0/src/everstack/resources/decisions.py +67 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/embeddings.py +3 -3
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/evaluations.py +23 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/models.py +3 -3
- everstack-0.2.0/src/everstack/resources/openai_agents.py +396 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/responses.py +11 -1
- everstack-0.2.0/src/everstack/resources/traces.py +1008 -0
- {everstack-0.1.0 → everstack-0.2.0}/tests/test_client.py +5 -5
- everstack-0.2.0/tests/test_decisions.py +32 -0
- everstack-0.2.0/tests/test_evals.py +111 -0
- everstack-0.2.0/tests/test_gateway_correctness.py +364 -0
- everstack-0.2.0/tests/test_generated_models.py +13 -0
- everstack-0.2.0/tests/test_openai_agents.py +180 -0
- everstack-0.2.0/tests/test_responses_stream.py +136 -0
- everstack-0.2.0/tests/test_sandbox_recovery.py +65 -0
- everstack-0.2.0/tests/test_traces_capture.py +139 -0
- {everstack-0.1.0 → everstack-0.2.0}/tests/test_transport.py +4 -4
- everstack-0.1.0/PKG-INFO +0 -52
- everstack-0.1.0/PLAN.md +0 -269
- everstack-0.1.0/README.md +0 -21
- everstack-0.1.0/examples/agents_basic.py +0 -26
- everstack-0.1.0/examples/chat_basic.py +0 -22
- everstack-0.1.0/examples/responses_api.py +0 -32
- everstack-0.1.0/scripts/generate_models.py +0 -195
- everstack-0.1.0/src/everstack/_version.py +0 -1
- everstack-0.1.0/src/everstack/generated/models.py +0 -2851
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/generated/__init__.py +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/py.typed +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/__init__.py +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/audio.py +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/datasets.py +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/images.py +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/moderations.py +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/observability.py +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/src/everstack/resources/rerank.py +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/tests/__init__.py +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/tests/test_errors.py +0 -0
- {everstack-0.1.0 → everstack-0.2.0}/tests/test_types.py +0 -0
|
@@ -8,6 +8,7 @@ bin/**
|
|
|
8
8
|
|
|
9
9
|
# Local environment variables
|
|
10
10
|
.env
|
|
11
|
+
.envrc
|
|
11
12
|
.env.local
|
|
12
13
|
.env.development.local
|
|
13
14
|
.env.test.local
|
|
@@ -88,3 +89,12 @@ qdrant_storage
|
|
|
88
89
|
# ewt
|
|
89
90
|
.env.worktree
|
|
90
91
|
.everstack/
|
|
92
|
+
|
|
93
|
+
# Local build artifacts / caches
|
|
94
|
+
fc-supervisor
|
|
95
|
+
.pnpm-store/
|
|
96
|
+
__pycache__/
|
|
97
|
+
*.pyc
|
|
98
|
+
|
|
99
|
+
# Locally built agent binary (go build at the repo root); never commit it.
|
|
100
|
+
/firecracker-agent
|
everstack-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: everstack
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: The official Python SDK for the Everstack AI platform
|
|
5
|
+
Project-URL: Homepage, https://everstack.ai
|
|
6
|
+
Project-URL: Documentation, https://docs.everstack.ai/sdks/python
|
|
7
|
+
Project-URL: Repository, https://github.com/everstacklabs/everstack-python
|
|
8
|
+
Author: Everstack Labs
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Requires-Dist: httpx<1.0,>=0.25.0
|
|
22
|
+
Requires-Dist: pydantic<3.0,>=2.0.0
|
|
23
|
+
Requires-Dist: typing-extensions>=4.7.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: mypy>=1.5; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff>=0.1; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# Everstack Python SDK
|
|
33
|
+
|
|
34
|
+
The official Python SDK for the [Everstack](https://everstack.ai) AI platform.
|
|
35
|
+
Requires Python 3.9 or later. Uses HTTP with httpx and Pydantic v2 response models.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install everstack
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
Set your gateway instance URL and API key before running the examples:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
export EVERSTACK_BASE_URL="https://<instance>.<region>.everstack.ai"
|
|
49
|
+
export EVERSTACK_API_KEY="your-api-key"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from everstack import Everstack
|
|
54
|
+
|
|
55
|
+
client = Everstack() # Reads the environment variables above.
|
|
56
|
+
# Or pass explicit values, with api_key as the first positional argument:
|
|
57
|
+
client.close()
|
|
58
|
+
client = Everstack("your-api-key", base_url="http://localhost:8089")
|
|
59
|
+
client.close()
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Both `Everstack` and `AsyncEverstack` resolve `base_url` in this order:
|
|
63
|
+
explicit `base_url`, `EVERSTACK_BASE_URL`, then `EVERSTACK_GATEWAY_URL`.
|
|
64
|
+
Trailing slashes and one trailing `/openai/v1` or `/v1` are removed.
|
|
65
|
+
There is no default gateway URL. Without a configured URL, construction raises
|
|
66
|
+
`ValueError` with this message:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
everstack: no base URL configured. Pass base_url or set EVERSTACK_BASE_URL to your gateway URL, e.g. https://<instance>.<region>.everstack.ai
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The API key resolves from the explicit `api_key` or `EVERSTACK_API_KEY` and is
|
|
73
|
+
sent as `x-evs-api-key`. An empty key is allowed, for example when using
|
|
74
|
+
`Everstack(base_url="https://example.test", access_token="user-access-token")`
|
|
75
|
+
for OpenAI Agents. `access_token` adds an Authorization Bearer header.
|
|
76
|
+
Optional constructor settings are `provider`, `org_id`, `user_id`, `headers`,
|
|
77
|
+
and `timeout` (seconds, default 60). Use `with` or `async with`, or call
|
|
78
|
+
`close()` (await it for the async client), to release HTTP connections.
|
|
79
|
+
|
|
80
|
+
## Synchronous chat
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from everstack import Everstack
|
|
84
|
+
|
|
85
|
+
with Everstack() as client:
|
|
86
|
+
response = client.chat.completions.create(
|
|
87
|
+
model="gpt-5.5",
|
|
88
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
89
|
+
)
|
|
90
|
+
print(response.choices[0].message.content)
|
|
91
|
+
|
|
92
|
+
for chunk in client.chat.completions.create(
|
|
93
|
+
model="gpt-5.5",
|
|
94
|
+
messages=[{"role": "user", "content": "Tell me a short joke"}],
|
|
95
|
+
stream=True,
|
|
96
|
+
):
|
|
97
|
+
for choice in chunk.choices:
|
|
98
|
+
print(choice.delta.content or "", end="", flush=True)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Chat calls use `/openai/v1/chat/completions`. Streaming accepts SSE or JSON
|
|
102
|
+
lines. If the gateway returns a single completion when SSE is disabled, the
|
|
103
|
+
SDK yields it as one `ChatCompletionChunk`.
|
|
104
|
+
|
|
105
|
+
## Asynchronous chat
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import asyncio
|
|
109
|
+
from everstack import AsyncEverstack
|
|
110
|
+
|
|
111
|
+
async def main():
|
|
112
|
+
async with AsyncEverstack() as client:
|
|
113
|
+
response = await client.chat.completions.create(
|
|
114
|
+
model="gpt-5.5",
|
|
115
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
116
|
+
)
|
|
117
|
+
print(response.choices[0].message.content)
|
|
118
|
+
|
|
119
|
+
stream = await client.chat.completions.create(
|
|
120
|
+
model="gpt-5.5",
|
|
121
|
+
messages=[{"role": "user", "content": "Tell me a short joke"}],
|
|
122
|
+
stream=True,
|
|
123
|
+
)
|
|
124
|
+
async for chunk in stream:
|
|
125
|
+
for choice in chunk.choices:
|
|
126
|
+
print(choice.delta.content or "", end="", flush=True)
|
|
127
|
+
|
|
128
|
+
asyncio.run(main())
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Embeddings and models
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from everstack import Everstack
|
|
135
|
+
|
|
136
|
+
with Everstack() as client:
|
|
137
|
+
embeddings = client.embeddings.create(
|
|
138
|
+
model="text-embedding-3-small", input="Hello world",
|
|
139
|
+
)
|
|
140
|
+
print(embeddings.data[0].embedding)
|
|
141
|
+
models = client.models.list()
|
|
142
|
+
for model in models.data:
|
|
143
|
+
print(model.id, model.owned_by)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
These calls use `/openai/v1/embeddings` and `/openai/v1/models` and return
|
|
147
|
+
`EmbeddingsResponse` and `ModelsListResponse`. Access fields as attributes,
|
|
148
|
+
or use `.model_dump()` for a dictionary. With `AsyncEverstack`, await
|
|
149
|
+
`client.embeddings.create(...)` and `client.models.list()`.
|
|
150
|
+
|
|
151
|
+
## Responses
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
from everstack import Everstack
|
|
155
|
+
|
|
156
|
+
with Everstack() as client:
|
|
157
|
+
response = client.responses.create(
|
|
158
|
+
model="gpt-5.5",
|
|
159
|
+
input=[{"role": "user", "content": "Hello!"}],
|
|
160
|
+
)
|
|
161
|
+
print(response.id, response.status)
|
|
162
|
+
for item in response.output:
|
|
163
|
+
print(item.content)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Non-streaming creation uses `/v1/responses` and returns a `ResponseObject`
|
|
167
|
+
from the final snapshot in the gateway's NDJSON response. A single JSON object
|
|
168
|
+
also works. Errors in any frame raise `APIError`, and an empty stream raises
|
|
169
|
+
`APIError("empty response stream", status_code=200)`.
|
|
170
|
+
`responses.get(response_id)`, `cancel(response_id)`, `delete(response_id)` and
|
|
171
|
+
`list(limit=10)` are also available. Await the same calls on `AsyncEverstack`.
|
|
172
|
+
For async streaming, await `client.responses.create(..., stream=True)` and
|
|
173
|
+
iterate the returned stream with `async for`.
|
|
174
|
+
|
|
175
|
+
## Streaming responses
|
|
176
|
+
|
|
177
|
+
`client.responses.create(..., stream=True)` yields the gateway's stream
|
|
178
|
+
frames as dicts, each wrapped as `{"result": {...}}`:
|
|
179
|
+
|
|
180
|
+
- a snapshot of the whole response (`status: "in_progress"` and the full
|
|
181
|
+
`output`) whenever its structure changes: a new output item or content part;
|
|
182
|
+
- a delta frame, with no `status` and no `output`, carrying only what one item
|
|
183
|
+
grew by. `result.delta.item_id` names the item, and
|
|
184
|
+
`result.delta.content_delta` (message text) or
|
|
185
|
+
`result.delta.arguments_delta` (function call arguments) is the fragment to
|
|
186
|
+
append. `output_index` and `content_index` locate the item and its content
|
|
187
|
+
part; like every zero-valued field they are omitted when 0;
|
|
188
|
+
- the final, full response (`status: "completed"`, `"failed"` or
|
|
189
|
+
`"incomplete"`).
|
|
190
|
+
|
|
191
|
+
To rebuild the output as it arrives, replace each item with a snapshot's
|
|
192
|
+
version and append each delta's fragment:
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
items = {}
|
|
196
|
+
for frame in client.responses.create(model="gpt-5.5", input=[...], stream=True):
|
|
197
|
+
res = frame.get("result", {})
|
|
198
|
+
delta = res.get("delta")
|
|
199
|
+
if delta:
|
|
200
|
+
item = items.setdefault(delta["item_id"], {"text": "", "arguments": ""})
|
|
201
|
+
item["text"] += delta.get("content_delta", "")
|
|
202
|
+
item["arguments"] += delta.get("arguments_delta", "")
|
|
203
|
+
continue
|
|
204
|
+
for out in res.get("output", []):
|
|
205
|
+
text = "".join(p.get("text", "") for p in out.get("content", []))
|
|
206
|
+
items[out["id"]] = {"text": text, "arguments": out.get("arguments", "")}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Errors
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
from everstack import APIError, Everstack, RateLimitError
|
|
213
|
+
|
|
214
|
+
with Everstack() as client:
|
|
215
|
+
try:
|
|
216
|
+
client.models.list()
|
|
217
|
+
except RateLimitError as error:
|
|
218
|
+
print(error.message, error.retry_after)
|
|
219
|
+
except APIError as error:
|
|
220
|
+
print(error.status_code, error.code, error.message)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
All SDK errors inherit from `EverstackError`. HTTP API errors expose
|
|
224
|
+
`status_code`, `code`, `param`, and `message`. HTTP status mapping:
|
|
225
|
+
|
|
226
|
+
| Status | Exception |
|
|
227
|
+
| --- | --- |
|
|
228
|
+
| 401 | `AuthenticationError` |
|
|
229
|
+
| 403 | `PermissionDeniedError` |
|
|
230
|
+
| 404 | `NotFoundError` |
|
|
231
|
+
| 429 | `RateLimitError` |
|
|
232
|
+
| 500 | `InternalServerError` |
|
|
233
|
+
| 503 | `ServiceUnavailableError` |
|
|
234
|
+
| Other HTTP errors | `APIError` |
|
|
235
|
+
|
|
236
|
+
`RateLimitError.retry_after` is a float in seconds when a numeric `Retry-After`
|
|
237
|
+
header is present, otherwise `None`. Errors inside successful response frames
|
|
238
|
+
raise `APIError`. Network timeouts raise `everstack.TimeoutError`, and
|
|
239
|
+
connection failures raise `everstack.ConnectionError`. `InvalidModelError`
|
|
240
|
+
is also exported for model validation errors.
|
|
241
|
+
|
|
242
|
+
## Client resources
|
|
243
|
+
|
|
244
|
+
Both clients expose these resources. Several management resources have different
|
|
245
|
+
sync and async method layouts; the examples below show the existing sync API.
|
|
246
|
+
|
|
247
|
+
| Resource | Synchronous API examples |
|
|
248
|
+
| --- | --- |
|
|
249
|
+
| `chat` | `chat.completions.create(...)` |
|
|
250
|
+
| `embeddings` | `embeddings.create(...)` |
|
|
251
|
+
| `models` | `models.list()` |
|
|
252
|
+
| `audio` | `audio.transcriptions.create(...)`, `audio.translations.create(...)`, `audio.speech.create(...)` |
|
|
253
|
+
| `images` | `images.generate(...)`, `images.edit(...)`, `images.create_variation(...)` |
|
|
254
|
+
| `moderations` | `moderations.create(...)` |
|
|
255
|
+
| `decisions` | `decisions.create(...)` |
|
|
256
|
+
| `rerank` | `rerank.create(...)` |
|
|
257
|
+
| `responses` | `responses.create(...)`, `get(...)`, `cancel(...)`, `delete(...)`, `list(...)` |
|
|
258
|
+
| `agents` | `agents.create(...)`, `agents.sessions.run_turn(session_id, user_input="Hello")`, `agents.memories.list(agent_id)` |
|
|
259
|
+
| `datasets` | `datasets.create(...)`, `datasets.items.create_batch(...)` |
|
|
260
|
+
| `evaluations` | `evaluations.runs.create(...)`, `evaluations.schedules.create(...)`, `evaluations.score(...)` |
|
|
261
|
+
| `observability` | `observability.metrics.get_dashboard(...)`, `observability.sessions.list(...)` |
|
|
262
|
+
| `traces` | `traces.get(trace_id=...)`, `traces.span(...)`, `traces.capture_exception(...)` |
|
|
263
|
+
| `openai_agents` | `openai_agents.connections.create(...)`, `openai_agents.sessions.create(...)` |
|
|
264
|
+
|
|
265
|
+
For example, async agent management uses `await client.agents.create_session(...)`
|
|
266
|
+
and `await client.agents.run_turn(session_id, user_input="Hello")`;
|
|
267
|
+
async observability uses `await client.observability.get_metrics_dashboard(...)`.
|
|
268
|
+
`client.capture_exception(...)` and `client.capture_message(...)` delegate to
|
|
269
|
+
`traces` (await these on the async client). Most management calls return plain
|
|
270
|
+
dictionaries; chat, embeddings, models and Responses return Pydantic models.
|
|
271
|
+
The package also exports `everstack.evals` helpers for pytest evaluation gating
|
|
272
|
+
and generated model aliases under `everstack.generated.models`.
|
|
273
|
+
|
|
274
|
+
## Examples and development
|
|
275
|
+
|
|
276
|
+
The `examples/` directory contains sync chat, async chat, agents, Responses,
|
|
277
|
+
evaluation gating and a live gateway smoke script. All use environment-based
|
|
278
|
+
configuration. Run `python scripts/check_examples.py` to check syntax, imports,
|
|
279
|
+
client construction and resource attribute chains without making gateway calls.
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
pytest -q tests
|
|
283
|
+
ruff check src/
|
|
284
|
+
mypy src/everstack/ --ignore-missing-imports
|
|
285
|
+
python scripts/generate_models.py
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Documentation
|
|
289
|
+
|
|
290
|
+
See [docs.everstack.ai/sdks/python](https://docs.everstack.ai/sdks/python).
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Everstack Python SDK
|
|
2
|
+
|
|
3
|
+
The official Python SDK for the [Everstack](https://everstack.ai) AI platform.
|
|
4
|
+
Requires Python 3.9 or later. Uses HTTP with httpx and Pydantic v2 response models.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pip install everstack
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Configuration
|
|
13
|
+
|
|
14
|
+
Set your gateway instance URL and API key before running the examples:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
export EVERSTACK_BASE_URL="https://<instance>.<region>.everstack.ai"
|
|
18
|
+
export EVERSTACK_API_KEY="your-api-key"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from everstack import Everstack
|
|
23
|
+
|
|
24
|
+
client = Everstack() # Reads the environment variables above.
|
|
25
|
+
# Or pass explicit values, with api_key as the first positional argument:
|
|
26
|
+
client.close()
|
|
27
|
+
client = Everstack("your-api-key", base_url="http://localhost:8089")
|
|
28
|
+
client.close()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Both `Everstack` and `AsyncEverstack` resolve `base_url` in this order:
|
|
32
|
+
explicit `base_url`, `EVERSTACK_BASE_URL`, then `EVERSTACK_GATEWAY_URL`.
|
|
33
|
+
Trailing slashes and one trailing `/openai/v1` or `/v1` are removed.
|
|
34
|
+
There is no default gateway URL. Without a configured URL, construction raises
|
|
35
|
+
`ValueError` with this message:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
everstack: no base URL configured. Pass base_url or set EVERSTACK_BASE_URL to your gateway URL, e.g. https://<instance>.<region>.everstack.ai
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The API key resolves from the explicit `api_key` or `EVERSTACK_API_KEY` and is
|
|
42
|
+
sent as `x-evs-api-key`. An empty key is allowed, for example when using
|
|
43
|
+
`Everstack(base_url="https://example.test", access_token="user-access-token")`
|
|
44
|
+
for OpenAI Agents. `access_token` adds an Authorization Bearer header.
|
|
45
|
+
Optional constructor settings are `provider`, `org_id`, `user_id`, `headers`,
|
|
46
|
+
and `timeout` (seconds, default 60). Use `with` or `async with`, or call
|
|
47
|
+
`close()` (await it for the async client), to release HTTP connections.
|
|
48
|
+
|
|
49
|
+
## Synchronous chat
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from everstack import Everstack
|
|
53
|
+
|
|
54
|
+
with Everstack() as client:
|
|
55
|
+
response = client.chat.completions.create(
|
|
56
|
+
model="gpt-5.5",
|
|
57
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
58
|
+
)
|
|
59
|
+
print(response.choices[0].message.content)
|
|
60
|
+
|
|
61
|
+
for chunk in client.chat.completions.create(
|
|
62
|
+
model="gpt-5.5",
|
|
63
|
+
messages=[{"role": "user", "content": "Tell me a short joke"}],
|
|
64
|
+
stream=True,
|
|
65
|
+
):
|
|
66
|
+
for choice in chunk.choices:
|
|
67
|
+
print(choice.delta.content or "", end="", flush=True)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Chat calls use `/openai/v1/chat/completions`. Streaming accepts SSE or JSON
|
|
71
|
+
lines. If the gateway returns a single completion when SSE is disabled, the
|
|
72
|
+
SDK yields it as one `ChatCompletionChunk`.
|
|
73
|
+
|
|
74
|
+
## Asynchronous chat
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import asyncio
|
|
78
|
+
from everstack import AsyncEverstack
|
|
79
|
+
|
|
80
|
+
async def main():
|
|
81
|
+
async with AsyncEverstack() as client:
|
|
82
|
+
response = await client.chat.completions.create(
|
|
83
|
+
model="gpt-5.5",
|
|
84
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
85
|
+
)
|
|
86
|
+
print(response.choices[0].message.content)
|
|
87
|
+
|
|
88
|
+
stream = await client.chat.completions.create(
|
|
89
|
+
model="gpt-5.5",
|
|
90
|
+
messages=[{"role": "user", "content": "Tell me a short joke"}],
|
|
91
|
+
stream=True,
|
|
92
|
+
)
|
|
93
|
+
async for chunk in stream:
|
|
94
|
+
for choice in chunk.choices:
|
|
95
|
+
print(choice.delta.content or "", end="", flush=True)
|
|
96
|
+
|
|
97
|
+
asyncio.run(main())
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Embeddings and models
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from everstack import Everstack
|
|
104
|
+
|
|
105
|
+
with Everstack() as client:
|
|
106
|
+
embeddings = client.embeddings.create(
|
|
107
|
+
model="text-embedding-3-small", input="Hello world",
|
|
108
|
+
)
|
|
109
|
+
print(embeddings.data[0].embedding)
|
|
110
|
+
models = client.models.list()
|
|
111
|
+
for model in models.data:
|
|
112
|
+
print(model.id, model.owned_by)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
These calls use `/openai/v1/embeddings` and `/openai/v1/models` and return
|
|
116
|
+
`EmbeddingsResponse` and `ModelsListResponse`. Access fields as attributes,
|
|
117
|
+
or use `.model_dump()` for a dictionary. With `AsyncEverstack`, await
|
|
118
|
+
`client.embeddings.create(...)` and `client.models.list()`.
|
|
119
|
+
|
|
120
|
+
## Responses
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from everstack import Everstack
|
|
124
|
+
|
|
125
|
+
with Everstack() as client:
|
|
126
|
+
response = client.responses.create(
|
|
127
|
+
model="gpt-5.5",
|
|
128
|
+
input=[{"role": "user", "content": "Hello!"}],
|
|
129
|
+
)
|
|
130
|
+
print(response.id, response.status)
|
|
131
|
+
for item in response.output:
|
|
132
|
+
print(item.content)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Non-streaming creation uses `/v1/responses` and returns a `ResponseObject`
|
|
136
|
+
from the final snapshot in the gateway's NDJSON response. A single JSON object
|
|
137
|
+
also works. Errors in any frame raise `APIError`, and an empty stream raises
|
|
138
|
+
`APIError("empty response stream", status_code=200)`.
|
|
139
|
+
`responses.get(response_id)`, `cancel(response_id)`, `delete(response_id)` and
|
|
140
|
+
`list(limit=10)` are also available. Await the same calls on `AsyncEverstack`.
|
|
141
|
+
For async streaming, await `client.responses.create(..., stream=True)` and
|
|
142
|
+
iterate the returned stream with `async for`.
|
|
143
|
+
|
|
144
|
+
## Streaming responses
|
|
145
|
+
|
|
146
|
+
`client.responses.create(..., stream=True)` yields the gateway's stream
|
|
147
|
+
frames as dicts, each wrapped as `{"result": {...}}`:
|
|
148
|
+
|
|
149
|
+
- a snapshot of the whole response (`status: "in_progress"` and the full
|
|
150
|
+
`output`) whenever its structure changes: a new output item or content part;
|
|
151
|
+
- a delta frame, with no `status` and no `output`, carrying only what one item
|
|
152
|
+
grew by. `result.delta.item_id` names the item, and
|
|
153
|
+
`result.delta.content_delta` (message text) or
|
|
154
|
+
`result.delta.arguments_delta` (function call arguments) is the fragment to
|
|
155
|
+
append. `output_index` and `content_index` locate the item and its content
|
|
156
|
+
part; like every zero-valued field they are omitted when 0;
|
|
157
|
+
- the final, full response (`status: "completed"`, `"failed"` or
|
|
158
|
+
`"incomplete"`).
|
|
159
|
+
|
|
160
|
+
To rebuild the output as it arrives, replace each item with a snapshot's
|
|
161
|
+
version and append each delta's fragment:
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
items = {}
|
|
165
|
+
for frame in client.responses.create(model="gpt-5.5", input=[...], stream=True):
|
|
166
|
+
res = frame.get("result", {})
|
|
167
|
+
delta = res.get("delta")
|
|
168
|
+
if delta:
|
|
169
|
+
item = items.setdefault(delta["item_id"], {"text": "", "arguments": ""})
|
|
170
|
+
item["text"] += delta.get("content_delta", "")
|
|
171
|
+
item["arguments"] += delta.get("arguments_delta", "")
|
|
172
|
+
continue
|
|
173
|
+
for out in res.get("output", []):
|
|
174
|
+
text = "".join(p.get("text", "") for p in out.get("content", []))
|
|
175
|
+
items[out["id"]] = {"text": text, "arguments": out.get("arguments", "")}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Errors
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from everstack import APIError, Everstack, RateLimitError
|
|
182
|
+
|
|
183
|
+
with Everstack() as client:
|
|
184
|
+
try:
|
|
185
|
+
client.models.list()
|
|
186
|
+
except RateLimitError as error:
|
|
187
|
+
print(error.message, error.retry_after)
|
|
188
|
+
except APIError as error:
|
|
189
|
+
print(error.status_code, error.code, error.message)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
All SDK errors inherit from `EverstackError`. HTTP API errors expose
|
|
193
|
+
`status_code`, `code`, `param`, and `message`. HTTP status mapping:
|
|
194
|
+
|
|
195
|
+
| Status | Exception |
|
|
196
|
+
| --- | --- |
|
|
197
|
+
| 401 | `AuthenticationError` |
|
|
198
|
+
| 403 | `PermissionDeniedError` |
|
|
199
|
+
| 404 | `NotFoundError` |
|
|
200
|
+
| 429 | `RateLimitError` |
|
|
201
|
+
| 500 | `InternalServerError` |
|
|
202
|
+
| 503 | `ServiceUnavailableError` |
|
|
203
|
+
| Other HTTP errors | `APIError` |
|
|
204
|
+
|
|
205
|
+
`RateLimitError.retry_after` is a float in seconds when a numeric `Retry-After`
|
|
206
|
+
header is present, otherwise `None`. Errors inside successful response frames
|
|
207
|
+
raise `APIError`. Network timeouts raise `everstack.TimeoutError`, and
|
|
208
|
+
connection failures raise `everstack.ConnectionError`. `InvalidModelError`
|
|
209
|
+
is also exported for model validation errors.
|
|
210
|
+
|
|
211
|
+
## Client resources
|
|
212
|
+
|
|
213
|
+
Both clients expose these resources. Several management resources have different
|
|
214
|
+
sync and async method layouts; the examples below show the existing sync API.
|
|
215
|
+
|
|
216
|
+
| Resource | Synchronous API examples |
|
|
217
|
+
| --- | --- |
|
|
218
|
+
| `chat` | `chat.completions.create(...)` |
|
|
219
|
+
| `embeddings` | `embeddings.create(...)` |
|
|
220
|
+
| `models` | `models.list()` |
|
|
221
|
+
| `audio` | `audio.transcriptions.create(...)`, `audio.translations.create(...)`, `audio.speech.create(...)` |
|
|
222
|
+
| `images` | `images.generate(...)`, `images.edit(...)`, `images.create_variation(...)` |
|
|
223
|
+
| `moderations` | `moderations.create(...)` |
|
|
224
|
+
| `decisions` | `decisions.create(...)` |
|
|
225
|
+
| `rerank` | `rerank.create(...)` |
|
|
226
|
+
| `responses` | `responses.create(...)`, `get(...)`, `cancel(...)`, `delete(...)`, `list(...)` |
|
|
227
|
+
| `agents` | `agents.create(...)`, `agents.sessions.run_turn(session_id, user_input="Hello")`, `agents.memories.list(agent_id)` |
|
|
228
|
+
| `datasets` | `datasets.create(...)`, `datasets.items.create_batch(...)` |
|
|
229
|
+
| `evaluations` | `evaluations.runs.create(...)`, `evaluations.schedules.create(...)`, `evaluations.score(...)` |
|
|
230
|
+
| `observability` | `observability.metrics.get_dashboard(...)`, `observability.sessions.list(...)` |
|
|
231
|
+
| `traces` | `traces.get(trace_id=...)`, `traces.span(...)`, `traces.capture_exception(...)` |
|
|
232
|
+
| `openai_agents` | `openai_agents.connections.create(...)`, `openai_agents.sessions.create(...)` |
|
|
233
|
+
|
|
234
|
+
For example, async agent management uses `await client.agents.create_session(...)`
|
|
235
|
+
and `await client.agents.run_turn(session_id, user_input="Hello")`;
|
|
236
|
+
async observability uses `await client.observability.get_metrics_dashboard(...)`.
|
|
237
|
+
`client.capture_exception(...)` and `client.capture_message(...)` delegate to
|
|
238
|
+
`traces` (await these on the async client). Most management calls return plain
|
|
239
|
+
dictionaries; chat, embeddings, models and Responses return Pydantic models.
|
|
240
|
+
The package also exports `everstack.evals` helpers for pytest evaluation gating
|
|
241
|
+
and generated model aliases under `everstack.generated.models`.
|
|
242
|
+
|
|
243
|
+
## Examples and development
|
|
244
|
+
|
|
245
|
+
The `examples/` directory contains sync chat, async chat, agents, Responses,
|
|
246
|
+
evaluation gating and a live gateway smoke script. All use environment-based
|
|
247
|
+
configuration. Run `python scripts/check_examples.py` to check syntax, imports,
|
|
248
|
+
client construction and resource attribute chains without making gateway calls.
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
pytest -q tests
|
|
252
|
+
ruff check src/
|
|
253
|
+
mypy src/everstack/ --ignore-missing-imports
|
|
254
|
+
python scripts/generate_models.py
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Documentation
|
|
258
|
+
|
|
259
|
+
See [docs.everstack.ai/sdks/python](https://docs.everstack.ai/sdks/python).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Agents resource example."""
|
|
2
|
+
|
|
3
|
+
from everstack import Everstack
|
|
4
|
+
|
|
5
|
+
def main() -> None:
|
|
6
|
+
client = Everstack()
|
|
7
|
+
|
|
8
|
+
# List agents
|
|
9
|
+
agents = client.agents.list()
|
|
10
|
+
for agent in agents.get("agents", []):
|
|
11
|
+
print(f" {agent['name']} ({agent['id']})")
|
|
12
|
+
|
|
13
|
+
# Create a session
|
|
14
|
+
session = client.agents.sessions.create(agent_id="agent_abc123")["session"]
|
|
15
|
+
print(f"Session: {session['id']}")
|
|
16
|
+
|
|
17
|
+
# Send a message
|
|
18
|
+
response = client.agents.sessions.run_turn(
|
|
19
|
+
session_id=session["id"],
|
|
20
|
+
user_input="Hello, agent!",
|
|
21
|
+
)
|
|
22
|
+
print(f"Response: {response}")
|
|
23
|
+
|
|
24
|
+
# List memories
|
|
25
|
+
memories = client.agents.memories.list(agent_id="agent_abc123")
|
|
26
|
+
for mem in memories.get("memories", []):
|
|
27
|
+
print(f" Memory: {mem['content'][:80]}...")
|
|
28
|
+
client.close()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if __name__ == "__main__":
|
|
32
|
+
main()
|
|
@@ -6,7 +6,7 @@ from everstack import AsyncEverstack
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
async def main() -> None:
|
|
9
|
-
async with AsyncEverstack(
|
|
9
|
+
async with AsyncEverstack() as client:
|
|
10
10
|
# Chat completion
|
|
11
11
|
response = await client.chat.completions.create(
|
|
12
12
|
model="@openai/gpt-4o",
|
|
@@ -19,11 +19,12 @@ async def main() -> None:
|
|
|
19
19
|
model="@openai/text-embedding-3-small",
|
|
20
20
|
input=["Hello world", "How are you?"],
|
|
21
21
|
)
|
|
22
|
-
print(f"Got {len(embeddings
|
|
22
|
+
print(f"Got {len(embeddings.data)} embeddings")
|
|
23
23
|
|
|
24
24
|
# List models
|
|
25
25
|
models = await client.models.list()
|
|
26
|
-
print(f"Available models: {len(models
|
|
26
|
+
print(f"Available models: {len(models.data)}")
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Basic chat completion example."""
|
|
2
|
+
|
|
3
|
+
from everstack import Everstack
|
|
4
|
+
|
|
5
|
+
def main() -> None:
|
|
6
|
+
client = Everstack()
|
|
7
|
+
|
|
8
|
+
# Simple chat completion
|
|
9
|
+
response = client.chat.completions.create(
|
|
10
|
+
model="@openai/gpt-4o",
|
|
11
|
+
messages=[{"role": "user", "content": "What is the capital of France?"}],
|
|
12
|
+
)
|
|
13
|
+
print(response.choices[0].message.content)
|
|
14
|
+
|
|
15
|
+
# Streaming
|
|
16
|
+
for chunk in client.chat.completions.create(
|
|
17
|
+
model="@anthropic/claude-3-5-sonnet-20241022",
|
|
18
|
+
messages=[{"role": "user", "content": "Tell me a short joke"}],
|
|
19
|
+
stream=True,
|
|
20
|
+
):
|
|
21
|
+
if chunk.choices and chunk.choices[0].delta.content:
|
|
22
|
+
print(chunk.choices[0].delta.content, end="", flush=True)
|
|
23
|
+
print()
|
|
24
|
+
client.close()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__ == "__main__":
|
|
28
|
+
main()
|