You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 14, 2025. It is now read-only.
@@ -10,7 +10,7 @@ It is generated with [Stainless](https://www.stainless.com/).
10
10
11
11
## Documentation
12
12
13
-
The full API of this library can be found in [api.md](api.md).
13
+
The REST API documentation can be found on [llama-stack.readthedocs.io](https://llama-stack.readthedocs.io/en/latest/). The full API of this library can be found in [api.md](api.md).
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
@@ -125,21 +159,37 @@ from llama_stack_client import LlamaStackClient
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
178
+
179
+
```python
180
+
from pathlib import Path
181
+
from llama_stack_client import LlamaStackClient
182
+
183
+
client = LlamaStackClient()
184
+
185
+
client.files.create(
186
+
file=Path("/path/to/file"),
187
+
purpose="assistants",
188
+
)
189
+
```
190
+
191
+
The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
192
+
143
193
## Handling errors
144
194
145
195
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `llama_stack_client.APIConnectionError` is raised.
@@ -156,9 +206,14 @@ from llama_stack_client import LlamaStackClient
156
206
client = LlamaStackClient()
157
207
158
208
try:
159
-
client.datasetio.append_rows(
160
-
dataset_id="REPLACE_ME",
161
-
rows=[{"foo": True}],
209
+
client.inference.chat_completion(
210
+
messages=[
211
+
{
212
+
"content": "string",
213
+
"role": "user",
214
+
}
215
+
],
216
+
model_id="model_id",
162
217
)
163
218
except llama_stack_client.APIConnectionError as e:
datasetio= response.parse() # get the object that `datasetio.append_rows()` would have returned
284
-
print(datasetio)
349
+
inference= response.parse() # get the object that `inference.chat_completion()` would have returned
350
+
print(inference.completion_message)
285
351
```
286
352
287
353
These methods return an [`APIResponse`](https://github.com/llamastack/llama-stack-client-python/tree/main/src/llama_stack_client/_response.py) object.
@@ -295,9 +361,14 @@ The above interface eagerly reads the full response body when you make the reque
295
361
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
296
362
297
363
```python
298
-
with client.datasetio.with_streaming_response.append_rows(
299
-
dataset_id="REPLACE_ME",
300
-
rows=[{"foo": True}],
364
+
with client.inference.with_streaming_response.chat_completion(
365
+
messages=[
366
+
{
367
+
"content": "string",
368
+
"role": "user",
369
+
}
370
+
],
371
+
model_id="model_id",
301
372
) as response:
302
373
print(response.headers.get("X-My-Header"))
303
374
@@ -354,7 +425,7 @@ import httpx
354
425
from llama_stack_client import LlamaStackClient, DefaultHttpxClient
355
426
356
427
client = LlamaStackClient(
357
-
# Or use the `LLAMA_STACK_CLIENT_BASE_URL` env var
0 commit comments