Skip to content

Commit c227b57

Browse files
feat(api): remove openai/v1 endpoints
1 parent 65cbe68 commit c227b57

26 files changed

+174
-719
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 112
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-a9f69d4a5f5d9bf957497cac83fdad1f72c8a44614098447762c53883e8bd987.yml
3-
openapi_spec_hash: 75de5bdff8e70591d6033b609fc24e5d
4-
config_hash: 34558d5f6e265184d712d43e231eb693
1+
configured_endpoints: 110
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-d95665c12a4155ef6ae80f76545152ac241d3ccab18148e4add99c0f528b9634.yml
3+
openapi_spec_hash: b6073c3436942c3ea6cd6c23f71a1cc4
4+
config_hash: 597b56196f814dd58c2cb2465aab9c9e

README.md

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,12 @@ The full API of this library can be found in [api.md](api.md). You may find basi
3131
```python
3232
from llama_stack_client import LlamaStackClient
3333

34-
client = LlamaStackClient(
35-
base_url=f"http://{host}:{port}",
36-
)
34+
client = LlamaStackClient()
3735

38-
response = client.chat.completions.create(
39-
messages=[{"role": "user", "content": "hello world, write me a 2 sentence poem about the moon"}],
40-
model="meta-llama/Llama-3.2-3B-Instruct",
41-
stream=False,
36+
response = client.models.register(
37+
model_id="model_id",
4238
)
43-
print(response)
39+
print(response.identifier)
4440
```
4541

4642
While you can provide an `api_key` keyword argument, we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/) to add `LLAMA_STACK_CLIENT_API_KEY="My API Key"` to your `.env` file so that your API Key is not stored in source control.
@@ -97,18 +93,49 @@ client = AsyncLlamaStackClient(
9793

9894

9995
async def main() -> None:
100-
session = await client.agents.sessions.create(
101-
agent_id="agent_id",
102-
session_name="session_name",
96+
response = await client.models.register(
97+
model_id="model_id",
10398
)
104-
print(session.session_id)
99+
print(response.identifier)
105100

106101

107102
asyncio.run(main())
108103
```
109104

110105
Functionality between the synchronous and asynchronous clients is otherwise identical.
111106

107+
### With aiohttp
108+
109+
By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.
110+
111+
You can enable this by installing `aiohttp`:
112+
113+
```sh
114+
# install from PyPI
115+
pip install --pre llama_stack_client[aiohttp]
116+
```
117+
118+
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
119+
120+
```python
121+
import asyncio
122+
from llama_stack_client import DefaultAioHttpClient
123+
from llama_stack_client import AsyncLlamaStackClient
124+
125+
126+
async def main() -> None:
127+
async with AsyncLlamaStackClient(
128+
http_client=DefaultAioHttpClient(),
129+
) as client:
130+
response = await client.models.register(
131+
model_id="model_id",
132+
)
133+
print(response.identifier)
134+
135+
136+
asyncio.run(main())
137+
```
138+
112139
## Streaming responses
113140

114141
We provide support for streaming responses using Server Side Events (SSE).

api.md

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ from llama_stack_client.types import (
77
Document,
88
InterleavedContent,
99
InterleavedContentItem,
10-
Message,
1110
ParamType,
1211
QueryConfig,
1312
QueryResult,
@@ -300,27 +299,27 @@ Methods:
300299
Types:
301300

302301
```python
303-
from llama_stack_client.types import ListModelsResponse, Model, ModelListResponse
302+
from llama_stack_client.types import (
303+
ListModelsResponse,
304+
Model,
305+
ModelRetrieveResponse,
306+
ModelListResponse,
307+
ModelRegisterResponse,
308+
)
304309
```
305310

306311
Methods:
307312

308-
- <code title="get /v1/models/{model_id}">client.models.<a href="./src/llama_stack_client/resources/models/models.py">retrieve</a>(model_id) -> <a href="./src/llama_stack_client/types/model.py">Model</a></code>
309-
- <code title="get /v1/openai/v1/models">client.models.<a href="./src/llama_stack_client/resources/models/models.py">list</a>() -> <a href="./src/llama_stack_client/types/model_list_response.py">ModelListResponse</a></code>
310-
- <code title="post /v1/models">client.models.<a href="./src/llama_stack_client/resources/models/models.py">register</a>(\*\*<a href="src/llama_stack_client/types/model_register_params.py">params</a>) -> <a href="./src/llama_stack_client/types/model.py">Model</a></code>
313+
- <code title="get /v1/models/{model_id}">client.models.<a href="./src/llama_stack_client/resources/models/models.py">retrieve</a>(model_id) -> <a href="./src/llama_stack_client/types/model_retrieve_response.py">ModelRetrieveResponse</a></code>
314+
- <code title="get /v1/models">client.models.<a href="./src/llama_stack_client/resources/models/models.py">list</a>() -> <a href="./src/llama_stack_client/types/model_list_response.py">ModelListResponse</a></code>
315+
- <code title="post /v1/models">client.models.<a href="./src/llama_stack_client/resources/models/models.py">register</a>(\*\*<a href="src/llama_stack_client/types/model_register_params.py">params</a>) -> <a href="./src/llama_stack_client/types/model_register_response.py">ModelRegisterResponse</a></code>
311316
- <code title="delete /v1/models/{model_id}">client.models.<a href="./src/llama_stack_client/resources/models/models.py">unregister</a>(model_id) -> None</code>
312317

313318
## OpenAI
314319

315-
Types:
316-
317-
```python
318-
from llama_stack_client.types.models import OpenAIListResponse
319-
```
320-
321320
Methods:
322321

323-
- <code title="get /v1/models">client.models.openai.<a href="./src/llama_stack_client/resources/models/openai.py">list</a>() -> <a href="./src/llama_stack_client/types/models/openai_list_response.py">OpenAIListResponse</a></code>
322+
- <code title="get /v1/models">client.models.openai.<a href="./src/llama_stack_client/resources/models/openai.py">list</a>() -> <a href="./src/llama_stack_client/types/model_list_response.py">ModelListResponse</a></code>
324323

325324
# Providers
326325

@@ -386,18 +385,6 @@ Methods:
386385
- <code title="delete /v1/shields/{identifier}">client.shields.<a href="./src/llama_stack_client/resources/shields.py">delete</a>(identifier) -> None</code>
387386
- <code title="post /v1/shields">client.shields.<a href="./src/llama_stack_client/resources/shields.py">register</a>(\*\*<a href="src/llama_stack_client/types/shield_register_params.py">params</a>) -> <a href="./src/llama_stack_client/types/shield.py">Shield</a></code>
388387

389-
# SyntheticDataGeneration
390-
391-
Types:
392-
393-
```python
394-
from llama_stack_client.types import SyntheticDataGenerationResponse
395-
```
396-
397-
Methods:
398-
399-
- <code title="post /v1/synthetic-data-generation/generate">client.synthetic_data_generation.<a href="./src/llama_stack_client/resources/synthetic_data_generation.py">generate</a>(\*\*<a href="src/llama_stack_client/types/synthetic_data_generation_generate_params.py">params</a>) -> <a href="./src/llama_stack_client/types/synthetic_data_generation_response.py">SyntheticDataGenerationResponse</a></code>
400-
401388
# Scoring
402389

403390
Types:

src/llama_stack_client/_client.py

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
conversations,
6363
vector_stores,
6464
scoring_functions,
65-
synthetic_data_generation,
6665
)
6766
from .resources.files import FilesResource, AsyncFilesResource
6867
from .resources.tools import ToolsResource, AsyncToolsResource
@@ -84,10 +83,6 @@
8483
from .resources.prompts.prompts import PromptsResource, AsyncPromptsResource
8584
from .resources.scoring_functions import ScoringFunctionsResource, AsyncScoringFunctionsResource
8685
from .resources.responses.responses import ResponsesResource, AsyncResponsesResource
87-
from .resources.synthetic_data_generation import (
88-
SyntheticDataGenerationResource,
89-
AsyncSyntheticDataGenerationResource,
90-
)
9186
from .resources.tool_runtime.tool_runtime import ToolRuntimeResource, AsyncToolRuntimeResource
9287
from .resources.conversations.conversations import ConversationsResource, AsyncConversationsResource
9388
from .resources.vector_stores.vector_stores import VectorStoresResource, AsyncVectorStoresResource
@@ -269,12 +264,6 @@ def shields(self) -> ShieldsResource:
269264

270265
return ShieldsResource(self)
271266

272-
@cached_property
273-
def synthetic_data_generation(self) -> SyntheticDataGenerationResource:
274-
from .resources.synthetic_data_generation import SyntheticDataGenerationResource
275-
276-
return SyntheticDataGenerationResource(self)
277-
278267
@cached_property
279268
def scoring(self) -> ScoringResource:
280269
from .resources.scoring import ScoringResource
@@ -585,12 +574,6 @@ def shields(self) -> AsyncShieldsResource:
585574

586575
return AsyncShieldsResource(self)
587576

588-
@cached_property
589-
def synthetic_data_generation(self) -> AsyncSyntheticDataGenerationResource:
590-
from .resources.synthetic_data_generation import AsyncSyntheticDataGenerationResource
591-
592-
return AsyncSyntheticDataGenerationResource(self)
593-
594577
@cached_property
595578
def scoring(self) -> AsyncScoringResource:
596579
from .resources.scoring import AsyncScoringResource
@@ -850,12 +833,6 @@ def shields(self) -> shields.ShieldsResourceWithRawResponse:
850833

851834
return ShieldsResourceWithRawResponse(self._client.shields)
852835

853-
@cached_property
854-
def synthetic_data_generation(self) -> synthetic_data_generation.SyntheticDataGenerationResourceWithRawResponse:
855-
from .resources.synthetic_data_generation import SyntheticDataGenerationResourceWithRawResponse
856-
857-
return SyntheticDataGenerationResourceWithRawResponse(self._client.synthetic_data_generation)
858-
859836
@cached_property
860837
def scoring(self) -> scoring.ScoringResourceWithRawResponse:
861838
from .resources.scoring import ScoringResourceWithRawResponse
@@ -1001,14 +978,6 @@ def shields(self) -> shields.AsyncShieldsResourceWithRawResponse:
1001978

1002979
return AsyncShieldsResourceWithRawResponse(self._client.shields)
1003980

1004-
@cached_property
1005-
def synthetic_data_generation(
1006-
self,
1007-
) -> synthetic_data_generation.AsyncSyntheticDataGenerationResourceWithRawResponse:
1008-
from .resources.synthetic_data_generation import AsyncSyntheticDataGenerationResourceWithRawResponse
1009-
1010-
return AsyncSyntheticDataGenerationResourceWithRawResponse(self._client.synthetic_data_generation)
1011-
1012981
@cached_property
1013982
def scoring(self) -> scoring.AsyncScoringResourceWithRawResponse:
1014983
from .resources.scoring import AsyncScoringResourceWithRawResponse
@@ -1154,14 +1123,6 @@ def shields(self) -> shields.ShieldsResourceWithStreamingResponse:
11541123

11551124
return ShieldsResourceWithStreamingResponse(self._client.shields)
11561125

1157-
@cached_property
1158-
def synthetic_data_generation(
1159-
self,
1160-
) -> synthetic_data_generation.SyntheticDataGenerationResourceWithStreamingResponse:
1161-
from .resources.synthetic_data_generation import SyntheticDataGenerationResourceWithStreamingResponse
1162-
1163-
return SyntheticDataGenerationResourceWithStreamingResponse(self._client.synthetic_data_generation)
1164-
11651126
@cached_property
11661127
def scoring(self) -> scoring.ScoringResourceWithStreamingResponse:
11671128
from .resources.scoring import ScoringResourceWithStreamingResponse
@@ -1307,14 +1268,6 @@ def shields(self) -> shields.AsyncShieldsResourceWithStreamingResponse:
13071268

13081269
return AsyncShieldsResourceWithStreamingResponse(self._client.shields)
13091270

1310-
@cached_property
1311-
def synthetic_data_generation(
1312-
self,
1313-
) -> synthetic_data_generation.AsyncSyntheticDataGenerationResourceWithStreamingResponse:
1314-
from .resources.synthetic_data_generation import AsyncSyntheticDataGenerationResourceWithStreamingResponse
1315-
1316-
return AsyncSyntheticDataGenerationResourceWithStreamingResponse(self._client.synthetic_data_generation)
1317-
13181271
@cached_property
13191272
def scoring(self) -> scoring.AsyncScoringResourceWithStreamingResponse:
13201273
from .resources.scoring import AsyncScoringResourceWithStreamingResponse

src/llama_stack_client/resources/__init__.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,6 @@
190190
ScoringFunctionsResourceWithStreamingResponse,
191191
AsyncScoringFunctionsResourceWithStreamingResponse,
192192
)
193-
from .synthetic_data_generation import (
194-
SyntheticDataGenerationResource,
195-
AsyncSyntheticDataGenerationResource,
196-
SyntheticDataGenerationResourceWithRawResponse,
197-
AsyncSyntheticDataGenerationResourceWithRawResponse,
198-
SyntheticDataGenerationResourceWithStreamingResponse,
199-
AsyncSyntheticDataGenerationResourceWithStreamingResponse,
200-
)
201193

202194
__all__ = [
203195
"ToolgroupsResource",
@@ -308,12 +300,6 @@
308300
"AsyncShieldsResourceWithRawResponse",
309301
"ShieldsResourceWithStreamingResponse",
310302
"AsyncShieldsResourceWithStreamingResponse",
311-
"SyntheticDataGenerationResource",
312-
"AsyncSyntheticDataGenerationResource",
313-
"SyntheticDataGenerationResourceWithRawResponse",
314-
"AsyncSyntheticDataGenerationResourceWithRawResponse",
315-
"SyntheticDataGenerationResourceWithStreamingResponse",
316-
"AsyncSyntheticDataGenerationResourceWithStreamingResponse",
317303
"ScoringResource",
318304
"AsyncScoringResource",
319305
"ScoringResourceWithRawResponse",

src/llama_stack_client/resources/models/models.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
async_to_streamed_response_wrapper,
3434
)
3535
from ..._wrappers import DataWrapper
36-
from ...types.model import Model
3736
from ..._base_client import make_request_options
3837
from ...types.model_list_response import ModelListResponse
38+
from ...types.model_register_response import ModelRegisterResponse
39+
from ...types.model_retrieve_response import ModelRetrieveResponse
3940

4041
__all__ = ["ModelsResource", "AsyncModelsResource"]
4142

@@ -74,7 +75,7 @@ def retrieve(
7475
extra_query: Query | None = None,
7576
extra_body: Body | None = None,
7677
timeout: float | httpx.Timeout | None | NotGiven = not_given,
77-
) -> Model:
78+
) -> ModelRetrieveResponse:
7879
"""Get model.
7980
8081
Get a model by its identifier.
@@ -95,7 +96,7 @@ def retrieve(
9596
options=make_request_options(
9697
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
9798
),
98-
cast_to=Model,
99+
cast_to=ModelRetrieveResponse,
99100
)
100101

101102
def list(
@@ -110,7 +111,7 @@ def list(
110111
) -> ModelListResponse:
111112
"""List models using the OpenAI API."""
112113
return self._get(
113-
"/v1/openai/v1/models",
114+
"/v1/models",
114115
options=make_request_options(
115116
extra_headers=extra_headers,
116117
extra_query=extra_query,
@@ -135,7 +136,7 @@ def register(
135136
extra_query: Query | None = None,
136137
extra_body: Body | None = None,
137138
timeout: float | httpx.Timeout | None | NotGiven = not_given,
138-
) -> Model:
139+
) -> ModelRegisterResponse:
139140
"""Register model.
140141
141142
Register a model.
@@ -174,7 +175,7 @@ def register(
174175
options=make_request_options(
175176
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
176177
),
177-
cast_to=Model,
178+
cast_to=ModelRegisterResponse,
178179
)
179180

180181
def unregister(
@@ -247,7 +248,7 @@ async def retrieve(
247248
extra_query: Query | None = None,
248249
extra_body: Body | None = None,
249250
timeout: float | httpx.Timeout | None | NotGiven = not_given,
250-
) -> Model:
251+
) -> ModelRetrieveResponse:
251252
"""Get model.
252253
253254
Get a model by its identifier.
@@ -268,7 +269,7 @@ async def retrieve(
268269
options=make_request_options(
269270
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
270271
),
271-
cast_to=Model,
272+
cast_to=ModelRetrieveResponse,
272273
)
273274

274275
async def list(
@@ -283,7 +284,7 @@ async def list(
283284
) -> ModelListResponse:
284285
"""List models using the OpenAI API."""
285286
return await self._get(
286-
"/v1/openai/v1/models",
287+
"/v1/models",
287288
options=make_request_options(
288289
extra_headers=extra_headers,
289290
extra_query=extra_query,
@@ -308,7 +309,7 @@ async def register(
308309
extra_query: Query | None = None,
309310
extra_body: Body | None = None,
310311
timeout: float | httpx.Timeout | None | NotGiven = not_given,
311-
) -> Model:
312+
) -> ModelRegisterResponse:
312313
"""Register model.
313314
314315
Register a model.
@@ -347,7 +348,7 @@ async def register(
347348
options=make_request_options(
348349
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
349350
),
350-
cast_to=Model,
351+
cast_to=ModelRegisterResponse,
351352
)
352353

353354
async def unregister(

0 commit comments

Comments
 (0)