From 93376fcbe864d4e8becd957301e6df15b3d803f8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 21:21:19 +0000 Subject: [PATCH 01/14] feat!: improve consistency of post-training API endpoints --- .stats.yml | 6 +++--- api.md | 6 +++--- src/resources/alpha/post-training/job.ts | 12 +++++------ .../alpha/post-training/job.test.ts | 20 +++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.stats.yml b/.stats.yml index 48be7ae..88fc8a2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-958e990011d6b4c27513743a151ec4c80c3103650a80027380d15f1d6b108e32.yml -openapi_spec_hash: 5b49d825dbc2a26726ca752914a65114 -config_hash: 19b84a0a93d566334ae134dafc71991f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-7082771a4cef842834c167a755a9eafb9e9f412349e06abae9ee0331adcc8c49.yml +openapi_spec_hash: 711015fd57cb31962ee3683ea7dafe32 +config_hash: 07e70c7f1980785685ea4f2618dfde62 diff --git a/api.md b/api.md index aeddd14..96b1c74 100644 --- a/api.md +++ b/api.md @@ -407,9 +407,9 @@ Types: Methods: - client.alpha.postTraining.job.list() -> JobListResponse -- client.alpha.postTraining.job.artifacts() -> JobArtifactsResponse -- client.alpha.postTraining.job.cancel() -> void -- client.alpha.postTraining.job.status() -> JobStatusResponse +- client.alpha.postTraining.job.artifacts(jobUuid) -> JobArtifactsResponse +- client.alpha.postTraining.job.cancel(jobUuid) -> void +- client.alpha.postTraining.job.status(jobUuid) -> JobStatusResponse ## Benchmarks diff --git a/src/resources/alpha/post-training/job.ts b/src/resources/alpha/post-training/job.ts index 07db269..4875053 100644 --- a/src/resources/alpha/post-training/job.ts +++ b/src/resources/alpha/post-training/job.ts @@ -23,15 +23,15 @@ export class Job extends APIResource { /** * Get the artifacts of a training job. */ - artifacts(options?: Core.RequestOptions): Core.APIPromise { - return this._client.get('/v1alpha/post-training/job/artifacts', options); + artifacts(jobUuid: string, options?: Core.RequestOptions): Core.APIPromise { + return this._client.get(`/v1alpha/post-training/jobs/${jobUuid}/artifacts`, options); } /** * Cancel a training job. */ - cancel(options?: Core.RequestOptions): Core.APIPromise { - return this._client.post('/v1alpha/post-training/job/cancel', { + cancel(jobUuid: string, options?: Core.RequestOptions): Core.APIPromise { + return this._client.post(`/v1alpha/post-training/jobs/${jobUuid}/cancel`, { ...options, headers: { Accept: '*/*', ...options?.headers }, }); @@ -40,8 +40,8 @@ export class Job extends APIResource { /** * Get the status of a training job. */ - status(options?: Core.RequestOptions): Core.APIPromise { - return this._client.get('/v1alpha/post-training/job/status', options); + status(jobUuid: string, options?: Core.RequestOptions): Core.APIPromise { + return this._client.get(`/v1alpha/post-training/jobs/${jobUuid}/status`, options); } } diff --git a/tests/api-resources/alpha/post-training/job.test.ts b/tests/api-resources/alpha/post-training/job.test.ts index 65b8717..1cb9288 100644 --- a/tests/api-resources/alpha/post-training/job.test.ts +++ b/tests/api-resources/alpha/post-training/job.test.ts @@ -31,7 +31,7 @@ describe('resource job', () => { }); test('artifacts', async () => { - const responsePromise = client.alpha.postTraining.job.artifacts(); + const responsePromise = client.alpha.postTraining.job.artifacts('job_uuid'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -44,12 +44,12 @@ describe('resource job', () => { test('artifacts: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.alpha.postTraining.job.artifacts({ path: '/_stainless_unknown_path' }), + client.alpha.postTraining.job.artifacts('job_uuid', { path: '/_stainless_unknown_path' }), ).rejects.toThrow(LlamaStackClient.NotFoundError); }); test('cancel', async () => { - const responsePromise = client.alpha.postTraining.job.cancel(); + const responsePromise = client.alpha.postTraining.job.cancel('job_uuid'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -61,13 +61,13 @@ describe('resource job', () => { test('cancel: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect(client.alpha.postTraining.job.cancel({ path: '/_stainless_unknown_path' })).rejects.toThrow( - LlamaStackClient.NotFoundError, - ); + await expect( + client.alpha.postTraining.job.cancel('job_uuid', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(LlamaStackClient.NotFoundError); }); test('status', async () => { - const responsePromise = client.alpha.postTraining.job.status(); + const responsePromise = client.alpha.postTraining.job.status('job_uuid'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -79,8 +79,8 @@ describe('resource job', () => { test('status: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect(client.alpha.postTraining.job.status({ path: '/_stainless_unknown_path' })).rejects.toThrow( - LlamaStackClient.NotFoundError, - ); + await expect( + client.alpha.postTraining.job.status('job_uuid', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(LlamaStackClient.NotFoundError); }); }); From cb7f4d9e3ee2d76eccde8a1ff36567c227b5500f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 02:12:20 +0000 Subject: [PATCH 02/14] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 88fc8a2..2aaffba 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-7082771a4cef842834c167a755a9eafb9e9f412349e06abae9ee0331adcc8c49.yml -openapi_spec_hash: 711015fd57cb31962ee3683ea7dafe32 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-86691b53475e783b25b6efea9ddc93bf8aafd62c1760b8ad7c0cc1e06d22a5a1.yml +openapi_spec_hash: 47488d835df701e5ca3c27763346024a config_hash: 07e70c7f1980785685ea4f2618dfde62 From 1286b396a69ae48b41ad125405f005264339116d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 08:26:38 +0000 Subject: [PATCH 03/14] chore(api): minor updates --- src/resources/chat/completions.ts | 2 +- src/resources/files.ts | 4 ++-- src/resources/responses/input-items.ts | 2 +- src/resources/responses/responses.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index f2b9074..1c3fc67 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -2916,7 +2916,7 @@ export interface CompletionListParams { model?: string | null; /** - * Sort order for paginated responses. + * The order to sort the chat completions by: "asc" or "desc". Defaults to "desc". */ order?: 'asc' | 'desc' | null; } diff --git a/src/resources/files.ts b/src/resources/files.ts index f127f6d..6c016d3 100644 --- a/src/resources/files.ts +++ b/src/resources/files.ts @@ -186,12 +186,12 @@ export namespace FileCreateParams { export interface FileListParams extends OpenAICursorPageParams { /** - * Sort order for paginated responses. + * Sort order by created_at timestamp ('asc' or 'desc'). */ order?: 'asc' | 'desc' | null; /** - * Valid purpose values for OpenAI Files API. + * Filter files by purpose. */ purpose?: 'assistants' | 'batch' | null; } diff --git a/src/resources/responses/input-items.ts b/src/resources/responses/input-items.ts index 74e3c29..fc48c46 100644 --- a/src/resources/responses/input-items.ts +++ b/src/resources/responses/input-items.ts @@ -618,7 +618,7 @@ export interface InputItemListParams { limit?: number | null; /** - * Sort order for paginated responses. + * The order to return the input items in. */ order?: 'asc' | 'desc' | null; } diff --git a/src/resources/responses/responses.ts b/src/resources/responses/responses.ts index 594651e..e79a302 100644 --- a/src/resources/responses/responses.ts +++ b/src/resources/responses/responses.ts @@ -4540,7 +4540,7 @@ export interface ResponseListParams extends OpenAICursorPageParams { model?: string | null; /** - * Sort order for paginated responses. + * The order to sort responses by when sorted by created_at ('asc' or 'desc'). */ order?: 'asc' | 'desc' | null; } From 11a1a20e82bae62f8210cb26091d3df8bf648f15 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 08:54:06 +0000 Subject: [PATCH 04/14] fix(vector_io): align Protocol signatures with request models --- .stats.yml | 4 ++-- tests/api-resources/vector-stores/file-batches.test.ts | 2 +- tests/api-resources/vector-stores/files.test.ts | 2 +- tests/api-resources/vector-stores/vector-stores.test.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2aaffba..a756918 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-86691b53475e783b25b6efea9ddc93bf8aafd62c1760b8ad7c0cc1e06d22a5a1.yml -openapi_spec_hash: 47488d835df701e5ca3c27763346024a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-8b51d3973d2f51c91cf9ca3e4d40fd78ae92ffb1063308828c245f7e3d7ec813.yml +openapi_spec_hash: cb486698ac88370772a873d1fef90968 config_hash: 07e70c7f1980785685ea4f2618dfde62 diff --git a/tests/api-resources/vector-stores/file-batches.test.ts b/tests/api-resources/vector-stores/file-batches.test.ts index 119ff19..effbf70 100644 --- a/tests/api-resources/vector-stores/file-batches.test.ts +++ b/tests/api-resources/vector-stores/file-batches.test.ts @@ -103,7 +103,7 @@ describe('resource fileBatches', () => { after: 'after', before: 'before', filter: 'filter', - limit: 0, + limit: 1, order: 'order', }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/vector-stores/files.test.ts b/tests/api-resources/vector-stores/files.test.ts index 9fc72a0..860e9b0 100644 --- a/tests/api-resources/vector-stores/files.test.ts +++ b/tests/api-resources/vector-stores/files.test.ts @@ -95,7 +95,7 @@ describe('resource files', () => { after: 'after', before: 'before', filter: 'completed', - limit: 0, + limit: 1, order: 'order', }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/vector-stores/vector-stores.test.ts b/tests/api-resources/vector-stores/vector-stores.test.ts index c089ca8..88c9f33 100644 --- a/tests/api-resources/vector-stores/vector-stores.test.ts +++ b/tests/api-resources/vector-stores/vector-stores.test.ts @@ -77,7 +77,7 @@ describe('resource vectorStores', () => { { after: 'after', before: 'before', - limit: 0, + limit: 1, order: 'order', }, { path: '/_stainless_unknown_path' }, From 2cffe2040a77c3310db5d1803fc3800b4dd72f28 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:29:27 +0000 Subject: [PATCH 05/14] chore(internal): avoid type checking errors with ts-reset --- src/streaming.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/streaming.ts b/src/streaming.ts index 9b25156..b62513c 100644 --- a/src/streaming.ts +++ b/src/streaming.ts @@ -39,7 +39,7 @@ export class Stream implements AsyncIterable { try { for await (const sse of _iterSSEMessages(response, controller)) { try { - yield JSON.parse(sse.data); + yield JSON.parse(sse.data) as Item; } catch (e) { console.error(`Could not parse message into JSON:`, sse.data); console.error(`From chunk:`, sse.raw); From 3119d6bb8a1d38d6fa1958daeed0fb5dbb12b1e1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 15:06:25 +0000 Subject: [PATCH 06/14] feat: Add truncation parameter support --- .stats.yml | 4 ++-- src/resources/responses/responses.ts | 6 ++++++ tests/api-resources/responses/responses.test.ts | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index a756918..60e9043 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-8b51d3973d2f51c91cf9ca3e4d40fd78ae92ffb1063308828c245f7e3d7ec813.yml -openapi_spec_hash: cb486698ac88370772a873d1fef90968 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-408a03048e7b2e79fd6495e59120ee5fc2ff71503be4a470529efaa88ca911e2.yml +openapi_spec_hash: 24512bdd1c4bf5b8770f6b8ddf0620d0 config_hash: 07e70c7f1980785685ea4f2618dfde62 diff --git a/src/resources/responses/responses.ts b/src/resources/responses/responses.ts index e79a302..ec2e685 100644 --- a/src/resources/responses/responses.ts +++ b/src/resources/responses/responses.ts @@ -3867,6 +3867,12 @@ export interface ResponseCreateParamsBase { | ResponseCreateParams.OpenAIResponseInputToolFunction | ResponseCreateParams.OpenAIResponseInputToolMcp > | null; + + /** + * Controls how the service truncates input when it exceeds the model context + * window. + */ + truncation?: 'auto' | 'disabled' | null; } export namespace ResponseCreateParams { diff --git a/tests/api-resources/responses/responses.test.ts b/tests/api-resources/responses/responses.test.ts index a3d8d40..7ab8dca 100644 --- a/tests/api-resources/responses/responses.test.ts +++ b/tests/api-resources/responses/responses.test.ts @@ -58,6 +58,7 @@ describe('resource responses', () => { }, tool_choice: 'auto', tools: [{ search_context_size: 'S?oC"high', type: 'web_search' }], + truncation: 'auto', }); }); From e6399ef9e8b34b6cf3238c4c8f8b7d0134a8788e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 20:25:07 +0000 Subject: [PATCH 07/14] feat: Add prompt_cache_key parameter support --- .stats.yml | 4 ++-- src/resources/chat/completions.ts | 5 +++++ src/resources/responses/responses.ts | 9 +++++++++ tests/api-resources/chat/completions.test.ts | 1 + tests/api-resources/responses/responses.test.ts | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 60e9043..137ef24 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-408a03048e7b2e79fd6495e59120ee5fc2ff71503be4a470529efaa88ca911e2.yml -openapi_spec_hash: 24512bdd1c4bf5b8770f6b8ddf0620d0 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-d6858fead41d2db69218aca5b3b7bc8fe300a1025484c486c3cb304ed39c48bc.yml +openapi_spec_hash: bb1cc7aff177fad17663182b20e964b6 config_hash: 07e70c7f1980785685ea4f2618dfde62 diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 1c3fc67..b9292e2 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -2444,6 +2444,11 @@ export interface CompletionCreateParamsBase { */ presence_penalty?: number | null; + /** + * A key to use when reading from or writing to the prompt cache. + */ + prompt_cache_key?: string | null; + /** * The effort level for reasoning models. */ diff --git a/src/resources/responses/responses.ts b/src/resources/responses/responses.ts index ec2e685..b68b4bb 100644 --- a/src/resources/responses/responses.ts +++ b/src/resources/responses/responses.ts @@ -130,6 +130,8 @@ export interface ResponseObject { */ prompt?: ResponseObject.Prompt | null; + prompt_cache_key?: string | null; + /** * Configuration for reasoning effort in OpenAI responses. * @@ -2498,6 +2500,8 @@ export interface ResponseListResponse { */ prompt?: ResponseListResponse.Prompt | null; + prompt_cache_key?: string | null; + /** * Configuration for reasoning effort in OpenAI responses. * @@ -3811,6 +3815,11 @@ export interface ResponseCreateParamsBase { */ prompt?: ResponseCreateParams.Prompt | null; + /** + * A key to use when reading from or writing to the prompt cache. + */ + prompt_cache_key?: string | null; + /** * Configuration for reasoning effort in OpenAI responses. * diff --git a/tests/api-resources/chat/completions.test.ts b/tests/api-resources/chat/completions.test.ts index 204665d..f3fdd35 100644 --- a/tests/api-resources/chat/completions.test.ts +++ b/tests/api-resources/chat/completions.test.ts @@ -46,6 +46,7 @@ describe('resource completions', () => { n: 1, parallel_tool_calls: true, presence_penalty: -2, + prompt_cache_key: 'prompt_cache_key', reasoning_effort: 'none', response_format: { type: 'text' }, safety_identifier: 'safety_identifier', diff --git a/tests/api-resources/responses/responses.test.ts b/tests/api-resources/responses/responses.test.ts index 7ab8dca..b68e5cc 100644 --- a/tests/api-resources/responses/responses.test.ts +++ b/tests/api-resources/responses/responses.test.ts @@ -42,6 +42,7 @@ describe('resource responses', () => { variables: { foo: { text: 'text', type: 'input_text' } }, version: 'version', }, + prompt_cache_key: 'prompt_cache_key', reasoning: { effort: 'none' }, safety_identifier: 'safety_identifier', store: true, From d7033cd2af32a823514135971b3775037992393c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 15:31:07 +0000 Subject: [PATCH 08/14] fix(inference): use flat response message model for chat/completions --- .stats.yml | 4 +- src/resources/chat/completions.ts | 786 +++--------------------------- 2 files changed, 71 insertions(+), 719 deletions(-) diff --git a/.stats.yml b/.stats.yml index 137ef24..fe02b16 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-d6858fead41d2db69218aca5b3b7bc8fe300a1025484c486c3cb304ed39c48bc.yml -openapi_spec_hash: bb1cc7aff177fad17663182b20e964b6 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-5c711749dbcc9575d8997ac3e0b2a2e45e20ef8de212cdb0fcceb7009b34cc48.yml +openapi_spec_hash: 8107eabfac6b422964ac2a6688844181 config_hash: 07e70c7f1980785685ea4f2618dfde62 diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index b9292e2..a5c097c 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -116,12 +116,7 @@ export namespace CompletionCreateResponse { /** * The message from the model. */ - message: - | Choice.OpenAIUserMessageParamOutput - | Choice.OpenAISystemMessageParam - | Choice.OpenAIAssistantMessageParamOutput - | Choice.OpenAIToolMessageParam - | Choice.OpenAIDeveloperMessageParam; + message: Choice.Message; /** * The log probabilities for the tokens in the message from an OpenAI-compatible @@ -132,195 +127,59 @@ export namespace CompletionCreateResponse { export namespace Choice { /** - * A message from the user in an OpenAI-compatible chat completion request. - */ - export interface OpenAIUserMessageParamOutput { - /** - * The content of the message, which can include text and other media. - */ - content: - | string - | Array< - | OpenAIUserMessageParamOutput.OpenAIChatCompletionContentPartTextParam - | OpenAIUserMessageParamOutput.OpenAIChatCompletionContentPartImageParam - | OpenAIUserMessageParamOutput.OpenAIFile - >; - - /** - * The name of the user message participant. - */ - name?: string | null; - - /** - * Must be 'user' to identify this as a user message. - */ - role?: 'user'; - } - - export namespace OpenAIUserMessageParamOutput { - /** - * Text content part for OpenAI-compatible chat completion messages. - */ - export interface OpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - - /** - * Image content part for OpenAI-compatible chat completion messages. - */ - export interface OpenAIChatCompletionContentPartImageParam { - /** - * Image URL specification and processing details. - */ - image_url: OpenAIChatCompletionContentPartImageParam.ImageURL; - - /** - * Must be 'image_url' to identify this as image content. - */ - type?: 'image_url'; - } - - export namespace OpenAIChatCompletionContentPartImageParam { - /** - * Image URL specification and processing details. - */ - export interface ImageURL { - /** - * URL of the image to include in the message. - */ - url: string; - - /** - * Level of detail for image processing. Can be 'low', 'high', or 'auto'. - */ - detail?: 'low' | 'high' | 'auto' | null; - } - } - - export interface OpenAIFile { - /** - * File specification. - */ - file: OpenAIFile.File; - - /** - * Must be 'file' to identify this as file content. - */ - type?: 'file'; - } - - export namespace OpenAIFile { - /** - * File specification. - */ - export interface File { - /** - * Base64-encoded file data. - */ - file_data?: string | null; - - /** - * ID of an uploaded file. - */ - file_id?: string | null; - - /** - * Name of the file. - */ - filename?: string | null; - } - } - } - - /** - * A system message providing instructions or context to the model. + * The message from the model. */ - export interface OpenAISystemMessageParam { + export interface Message { /** - * The content of the 'system prompt'. If multiple system messages are provided, - * they are concatenated. + * Annotations for the message, when applicable. */ - content: string | Array; + annotations?: Array<{ [key: string]: unknown }>; /** - * The name of the system message participant. + * Audio response data when using audio output modality. */ - name?: string | null; + audio?: { [key: string]: unknown } | null; /** - * Must be 'system' to identify this as a system message. + * The content of the message. */ - role?: 'system'; - } + content?: string | null; - export namespace OpenAISystemMessageParam { /** - * Text content part for OpenAI-compatible chat completion messages. + * Deprecated: the name and arguments of a function that should be called. */ - export interface ListOpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - } - - /** - * A message containing the model's (assistant) response in an OpenAI-compatible - * chat completion request. - */ - export interface OpenAIAssistantMessageParamOutput { - /** - * The content of the model's response. - */ - content?: - | string - | Array - | null; + function_call?: Message.FunctionCall; /** - * The name of the assistant message participant. + * The refusal message generated by the model. */ - name?: string | null; + refusal?: string | null; /** - * Must be 'assistant' to identify this as the model's response. + * The role of the message author, always 'assistant' in responses. */ role?: 'assistant'; /** - * List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object. + * The tool calls generated by the model. */ - tool_calls?: Array | null; + tool_calls?: Array; } - export namespace OpenAIAssistantMessageParamOutput { + export namespace Message { /** - * Text content part for OpenAI-compatible chat completion messages. + * Deprecated: the name and arguments of a function that should be called. */ - export interface ListOpenAIChatCompletionContentPartTextParam { + export interface FunctionCall { /** - * The text content of the message. + * Arguments to pass to the function as a JSON string. */ - text: string; + arguments?: string | null; /** - * Must be 'text' to identify this as text content. + * Name of the function to call. */ - type?: 'text'; + name?: string | null; } /** @@ -366,81 +225,6 @@ export namespace CompletionCreateResponse { } } - /** - * A message representing the result of a tool invocation in an OpenAI-compatible - * chat completion request. - */ - export interface OpenAIToolMessageParam { - /** - * The response content from the tool. - */ - content: string | Array; - - /** - * Unique identifier for the tool call this response is for. - */ - tool_call_id: string; - - /** - * Must be 'tool' to identify this as a tool response. - */ - role?: 'tool'; - } - - export namespace OpenAIToolMessageParam { - /** - * Text content part for OpenAI-compatible chat completion messages. - */ - export interface ListOpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - } - - /** - * A message from the developer in an OpenAI-compatible chat completion request. - */ - export interface OpenAIDeveloperMessageParam { - /** - * The content of the developer message. - */ - content: string | Array; - - /** - * The name of the developer message participant. - */ - name?: string | null; - - /** - * Must be 'developer' to identify this as a developer message. - */ - role?: 'developer'; - } - - export namespace OpenAIDeveloperMessageParam { - /** - * Text content part for OpenAI-compatible chat completion messages. - */ - export interface ListOpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - } - /** * The log probabilities for the tokens in the message from an OpenAI-compatible * chat completion response. @@ -672,12 +456,7 @@ export namespace CompletionRetrieveResponse { /** * The message from the model. */ - message: - | Choice.OpenAIUserMessageParamOutput - | Choice.OpenAISystemMessageParam - | Choice.OpenAIAssistantMessageParamOutput - | Choice.OpenAIToolMessageParam - | Choice.OpenAIDeveloperMessageParam; + message: Choice.Message; /** * The log probabilities for the tokens in the message from an OpenAI-compatible @@ -688,195 +467,59 @@ export namespace CompletionRetrieveResponse { export namespace Choice { /** - * A message from the user in an OpenAI-compatible chat completion request. - */ - export interface OpenAIUserMessageParamOutput { - /** - * The content of the message, which can include text and other media. - */ - content: - | string - | Array< - | OpenAIUserMessageParamOutput.OpenAIChatCompletionContentPartTextParam - | OpenAIUserMessageParamOutput.OpenAIChatCompletionContentPartImageParam - | OpenAIUserMessageParamOutput.OpenAIFile - >; - - /** - * The name of the user message participant. - */ - name?: string | null; - - /** - * Must be 'user' to identify this as a user message. - */ - role?: 'user'; - } - - export namespace OpenAIUserMessageParamOutput { - /** - * Text content part for OpenAI-compatible chat completion messages. - */ - export interface OpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - - /** - * Image content part for OpenAI-compatible chat completion messages. - */ - export interface OpenAIChatCompletionContentPartImageParam { - /** - * Image URL specification and processing details. - */ - image_url: OpenAIChatCompletionContentPartImageParam.ImageURL; - - /** - * Must be 'image_url' to identify this as image content. - */ - type?: 'image_url'; - } - - export namespace OpenAIChatCompletionContentPartImageParam { - /** - * Image URL specification and processing details. - */ - export interface ImageURL { - /** - * URL of the image to include in the message. - */ - url: string; - - /** - * Level of detail for image processing. Can be 'low', 'high', or 'auto'. - */ - detail?: 'low' | 'high' | 'auto' | null; - } - } - - export interface OpenAIFile { - /** - * File specification. - */ - file: OpenAIFile.File; - - /** - * Must be 'file' to identify this as file content. - */ - type?: 'file'; - } - - export namespace OpenAIFile { - /** - * File specification. - */ - export interface File { - /** - * Base64-encoded file data. - */ - file_data?: string | null; - - /** - * ID of an uploaded file. - */ - file_id?: string | null; - - /** - * Name of the file. - */ - filename?: string | null; - } - } - } - - /** - * A system message providing instructions or context to the model. + * The message from the model. */ - export interface OpenAISystemMessageParam { - /** - * The content of the 'system prompt'. If multiple system messages are provided, - * they are concatenated. - */ - content: string | Array; - + export interface Message { /** - * The name of the system message participant. + * Annotations for the message, when applicable. */ - name?: string | null; + annotations?: Array<{ [key: string]: unknown }>; /** - * Must be 'system' to identify this as a system message. + * Audio response data when using audio output modality. */ - role?: 'system'; - } + audio?: { [key: string]: unknown } | null; - export namespace OpenAISystemMessageParam { /** - * Text content part for OpenAI-compatible chat completion messages. + * The content of the message. */ - export interface ListOpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - } + content?: string | null; - /** - * A message containing the model's (assistant) response in an OpenAI-compatible - * chat completion request. - */ - export interface OpenAIAssistantMessageParamOutput { /** - * The content of the model's response. + * Deprecated: the name and arguments of a function that should be called. */ - content?: - | string - | Array - | null; + function_call?: Message.FunctionCall; /** - * The name of the assistant message participant. + * The refusal message generated by the model. */ - name?: string | null; + refusal?: string | null; /** - * Must be 'assistant' to identify this as the model's response. + * The role of the message author, always 'assistant' in responses. */ role?: 'assistant'; /** - * List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object. + * The tool calls generated by the model. */ - tool_calls?: Array | null; + tool_calls?: Array; } - export namespace OpenAIAssistantMessageParamOutput { + export namespace Message { /** - * Text content part for OpenAI-compatible chat completion messages. + * Deprecated: the name and arguments of a function that should be called. */ - export interface ListOpenAIChatCompletionContentPartTextParam { + export interface FunctionCall { /** - * The text content of the message. + * Arguments to pass to the function as a JSON string. */ - text: string; + arguments?: string | null; /** - * Must be 'text' to identify this as text content. + * Name of the function to call. */ - type?: 'text'; + name?: string | null; } /** @@ -922,81 +565,6 @@ export namespace CompletionRetrieveResponse { } } - /** - * A message representing the result of a tool invocation in an OpenAI-compatible - * chat completion request. - */ - export interface OpenAIToolMessageParam { - /** - * The response content from the tool. - */ - content: string | Array; - - /** - * Unique identifier for the tool call this response is for. - */ - tool_call_id: string; - - /** - * Must be 'tool' to identify this as a tool response. - */ - role?: 'tool'; - } - - export namespace OpenAIToolMessageParam { - /** - * Text content part for OpenAI-compatible chat completion messages. - */ - export interface ListOpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - } - - /** - * A message from the developer in an OpenAI-compatible chat completion request. - */ - export interface OpenAIDeveloperMessageParam { - /** - * The content of the developer message. - */ - content: string | Array; - - /** - * The name of the developer message participant. - */ - name?: string | null; - - /** - * Must be 'developer' to identify this as a developer message. - */ - role?: 'developer'; - } - - export namespace OpenAIDeveloperMessageParam { - /** - * Text content part for OpenAI-compatible chat completion messages. - */ - export interface ListOpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - } - /** * The log probabilities for the tokens in the message from an OpenAI-compatible * chat completion response. @@ -1569,12 +1137,7 @@ export namespace CompletionListResponse { /** * The message from the model. */ - message: - | Choice.OpenAIUserMessageParamOutput - | Choice.OpenAISystemMessageParam - | Choice.OpenAIAssistantMessageParamOutput - | Choice.OpenAIToolMessageParam - | Choice.OpenAIDeveloperMessageParam; + message: Choice.Message; /** * The log probabilities for the tokens in the message from an OpenAI-compatible @@ -1585,195 +1148,59 @@ export namespace CompletionListResponse { export namespace Choice { /** - * A message from the user in an OpenAI-compatible chat completion request. - */ - export interface OpenAIUserMessageParamOutput { - /** - * The content of the message, which can include text and other media. - */ - content: - | string - | Array< - | OpenAIUserMessageParamOutput.OpenAIChatCompletionContentPartTextParam - | OpenAIUserMessageParamOutput.OpenAIChatCompletionContentPartImageParam - | OpenAIUserMessageParamOutput.OpenAIFile - >; - - /** - * The name of the user message participant. - */ - name?: string | null; - - /** - * Must be 'user' to identify this as a user message. - */ - role?: 'user'; - } - - export namespace OpenAIUserMessageParamOutput { - /** - * Text content part for OpenAI-compatible chat completion messages. - */ - export interface OpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - - /** - * Image content part for OpenAI-compatible chat completion messages. - */ - export interface OpenAIChatCompletionContentPartImageParam { - /** - * Image URL specification and processing details. - */ - image_url: OpenAIChatCompletionContentPartImageParam.ImageURL; - - /** - * Must be 'image_url' to identify this as image content. - */ - type?: 'image_url'; - } - - export namespace OpenAIChatCompletionContentPartImageParam { - /** - * Image URL specification and processing details. - */ - export interface ImageURL { - /** - * URL of the image to include in the message. - */ - url: string; - - /** - * Level of detail for image processing. Can be 'low', 'high', or 'auto'. - */ - detail?: 'low' | 'high' | 'auto' | null; - } - } - - export interface OpenAIFile { - /** - * File specification. - */ - file: OpenAIFile.File; - - /** - * Must be 'file' to identify this as file content. - */ - type?: 'file'; - } - - export namespace OpenAIFile { - /** - * File specification. - */ - export interface File { - /** - * Base64-encoded file data. - */ - file_data?: string | null; - - /** - * ID of an uploaded file. - */ - file_id?: string | null; - - /** - * Name of the file. - */ - filename?: string | null; - } - } - } - - /** - * A system message providing instructions or context to the model. + * The message from the model. */ - export interface OpenAISystemMessageParam { + export interface Message { /** - * The content of the 'system prompt'. If multiple system messages are provided, - * they are concatenated. + * Annotations for the message, when applicable. */ - content: string | Array; + annotations?: Array<{ [key: string]: unknown }>; /** - * The name of the system message participant. + * Audio response data when using audio output modality. */ - name?: string | null; - - /** - * Must be 'system' to identify this as a system message. - */ - role?: 'system'; - } + audio?: { [key: string]: unknown } | null; - export namespace OpenAISystemMessageParam { /** - * Text content part for OpenAI-compatible chat completion messages. + * The content of the message. */ - export interface ListOpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - } + content?: string | null; - /** - * A message containing the model's (assistant) response in an OpenAI-compatible - * chat completion request. - */ - export interface OpenAIAssistantMessageParamOutput { /** - * The content of the model's response. + * Deprecated: the name and arguments of a function that should be called. */ - content?: - | string - | Array - | null; + function_call?: Message.FunctionCall; /** - * The name of the assistant message participant. + * The refusal message generated by the model. */ - name?: string | null; + refusal?: string | null; /** - * Must be 'assistant' to identify this as the model's response. + * The role of the message author, always 'assistant' in responses. */ role?: 'assistant'; /** - * List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object. + * The tool calls generated by the model. */ - tool_calls?: Array | null; + tool_calls?: Array; } - export namespace OpenAIAssistantMessageParamOutput { + export namespace Message { /** - * Text content part for OpenAI-compatible chat completion messages. + * Deprecated: the name and arguments of a function that should be called. */ - export interface ListOpenAIChatCompletionContentPartTextParam { + export interface FunctionCall { /** - * The text content of the message. + * Arguments to pass to the function as a JSON string. */ - text: string; + arguments?: string | null; /** - * Must be 'text' to identify this as text content. + * Name of the function to call. */ - type?: 'text'; + name?: string | null; } /** @@ -1819,81 +1246,6 @@ export namespace CompletionListResponse { } } - /** - * A message representing the result of a tool invocation in an OpenAI-compatible - * chat completion request. - */ - export interface OpenAIToolMessageParam { - /** - * The response content from the tool. - */ - content: string | Array; - - /** - * Unique identifier for the tool call this response is for. - */ - tool_call_id: string; - - /** - * Must be 'tool' to identify this as a tool response. - */ - role?: 'tool'; - } - - export namespace OpenAIToolMessageParam { - /** - * Text content part for OpenAI-compatible chat completion messages. - */ - export interface ListOpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - } - - /** - * A message from the developer in an OpenAI-compatible chat completion request. - */ - export interface OpenAIDeveloperMessageParam { - /** - * The content of the developer message. - */ - content: string | Array; - - /** - * The name of the developer message participant. - */ - name?: string | null; - - /** - * Must be 'developer' to identify this as a developer message. - */ - role?: 'developer'; - } - - export namespace OpenAIDeveloperMessageParam { - /** - * Text content part for OpenAI-compatible chat completion messages. - */ - export interface ListOpenAIChatCompletionContentPartTextParam { - /** - * The text content of the message. - */ - text: string; - - /** - * Must be 'text' to identify this as text content. - */ - type?: 'text'; - } - } - /** * The log probabilities for the tokens in the message from an OpenAI-compatible * chat completion response. From 681979153c86faea86837512611f0ecebb79a22b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 20:01:53 +0000 Subject: [PATCH 09/14] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fe02b16..3635da5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-5c711749dbcc9575d8997ac3e0b2a2e45e20ef8de212cdb0fcceb7009b34cc48.yml openapi_spec_hash: 8107eabfac6b422964ac2a6688844181 -config_hash: 07e70c7f1980785685ea4f2618dfde62 +config_hash: 6aa61d4143c3e3df785972c0287d1370 From 6fa6eb87d96902586d4feb82747a5cdf99622045 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 15:32:07 +0000 Subject: [PATCH 10/14] fix: align chat completion usage schema with OpenAI spec --- .stats.yml | 4 +- src/resources/chat/chat.ts | 35 +++--- src/resources/chat/completions.ts | 114 ++++++++++-------- src/resources/responses/responses.ts | 33 +++++ tests/api-resources/chat/completions.test.ts | 1 + .../api-resources/responses/responses.test.ts | 1 + 6 files changed, 124 insertions(+), 64 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3635da5..efd970f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-5c711749dbcc9575d8997ac3e0b2a2e45e20ef8de212cdb0fcceb7009b34cc48.yml -openapi_spec_hash: 8107eabfac6b422964ac2a6688844181 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-10d6272b97f89f39692d8a734fe1e42de97b2ccc1cd56bc16113d15dff59b8dc.yml +openapi_spec_hash: 69cdb9b6b2edc70ac3c70761a352d992 config_hash: 6aa61d4143c3e3df785972c0287d1370 diff --git a/src/resources/chat/chat.ts b/src/resources/chat/chat.ts index 631c779..8cb5b41 100644 --- a/src/resources/chat/chat.ts +++ b/src/resources/chat/chat.ts @@ -53,7 +53,12 @@ export interface ChatCompletionChunk { object?: 'chat.completion.chunk'; /** - * Usage information for OpenAI chat completion. + * The service tier that was used for this response. + */ + service_tier?: string | null; + + /** + * Token usage information (typically included in final chunk with stream_options). */ usage?: ChatCompletionChunk.Usage | null; } @@ -278,54 +283,54 @@ export namespace ChatCompletionChunk { } /** - * Usage information for OpenAI chat completion. + * Token usage information (typically included in final chunk with stream_options). */ export interface Usage { /** * Number of tokens in the completion. */ - completion_tokens: number; + completion_tokens?: number; /** - * Number of tokens in the prompt. + * Detailed breakdown of output token usage. */ - prompt_tokens: number; + completion_tokens_details?: Usage.CompletionTokensDetails; /** - * Total tokens used (prompt + completion). + * Number of tokens in the prompt. */ - total_tokens: number; + prompt_tokens?: number; /** - * Token details for output tokens in OpenAI chat completion usage. + * Detailed breakdown of input token usage. */ - completion_tokens_details?: Usage.CompletionTokensDetails | null; + prompt_tokens_details?: Usage.PromptTokensDetails; /** - * Token details for prompt tokens in OpenAI chat completion usage. + * Total tokens used (prompt + completion). */ - prompt_tokens_details?: Usage.PromptTokensDetails | null; + total_tokens?: number; } export namespace Usage { /** - * Token details for output tokens in OpenAI chat completion usage. + * Detailed breakdown of output token usage. */ export interface CompletionTokensDetails { /** * Number of tokens used for reasoning (o1/o3 models). */ - reasoning_tokens?: number | null; + reasoning_tokens?: number; } /** - * Token details for prompt tokens in OpenAI chat completion usage. + * Detailed breakdown of input token usage. */ export interface PromptTokensDetails { /** * Number of tokens retrieved from cache. */ - cached_tokens?: number | null; + cached_tokens?: number; } } } diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index a5c097c..f562d71 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -93,7 +93,12 @@ export interface CompletionCreateResponse { object?: 'chat.completion'; /** - * Usage information for OpenAI chat completion. + * The service tier that was used for this response. + */ + service_tier?: string | null; + + /** + * Token usage information for the completion. */ usage?: CompletionCreateResponse.Usage | null; } @@ -343,54 +348,54 @@ export namespace CompletionCreateResponse { } /** - * Usage information for OpenAI chat completion. + * Token usage information for the completion. */ export interface Usage { /** * Number of tokens in the completion. */ - completion_tokens: number; + completion_tokens?: number; /** - * Number of tokens in the prompt. + * Detailed breakdown of output token usage. */ - prompt_tokens: number; + completion_tokens_details?: Usage.CompletionTokensDetails; /** - * Total tokens used (prompt + completion). + * Number of tokens in the prompt. */ - total_tokens: number; + prompt_tokens?: number; /** - * Token details for output tokens in OpenAI chat completion usage. + * Detailed breakdown of input token usage. */ - completion_tokens_details?: Usage.CompletionTokensDetails | null; + prompt_tokens_details?: Usage.PromptTokensDetails; /** - * Token details for prompt tokens in OpenAI chat completion usage. + * Total tokens used (prompt + completion). */ - prompt_tokens_details?: Usage.PromptTokensDetails | null; + total_tokens?: number; } export namespace Usage { /** - * Token details for output tokens in OpenAI chat completion usage. + * Detailed breakdown of output token usage. */ export interface CompletionTokensDetails { /** * Number of tokens used for reasoning (o1/o3 models). */ - reasoning_tokens?: number | null; + reasoning_tokens?: number; } /** - * Token details for prompt tokens in OpenAI chat completion usage. + * Detailed breakdown of input token usage. */ export interface PromptTokensDetails { /** * Number of tokens retrieved from cache. */ - cached_tokens?: number | null; + cached_tokens?: number; } } } @@ -433,9 +438,14 @@ export interface CompletionRetrieveResponse { object?: 'chat.completion'; /** - * Usage information for OpenAI chat completion. + * The service tier that was used for this response. + */ + service_tier?: string | null; + + /** + * Token usage information for the completion. */ - usage?: CompletionRetrieveResponse.Usage | null; + usage?: CompletionRetrieveResponse.Usage; } export namespace CompletionRetrieveResponse { @@ -993,54 +1003,54 @@ export namespace CompletionRetrieveResponse { } /** - * Usage information for OpenAI chat completion. + * Token usage information for the completion. */ export interface Usage { /** * Number of tokens in the completion. */ - completion_tokens: number; + completion_tokens?: number; /** - * Number of tokens in the prompt. + * Detailed breakdown of output token usage. */ - prompt_tokens: number; + completion_tokens_details?: Usage.CompletionTokensDetails; /** - * Total tokens used (prompt + completion). + * Number of tokens in the prompt. */ - total_tokens: number; + prompt_tokens?: number; /** - * Token details for output tokens in OpenAI chat completion usage. + * Detailed breakdown of input token usage. */ - completion_tokens_details?: Usage.CompletionTokensDetails | null; + prompt_tokens_details?: Usage.PromptTokensDetails; /** - * Token details for prompt tokens in OpenAI chat completion usage. + * Total tokens used (prompt + completion). */ - prompt_tokens_details?: Usage.PromptTokensDetails | null; + total_tokens?: number; } export namespace Usage { /** - * Token details for output tokens in OpenAI chat completion usage. + * Detailed breakdown of output token usage. */ export interface CompletionTokensDetails { /** * Number of tokens used for reasoning (o1/o3 models). */ - reasoning_tokens?: number | null; + reasoning_tokens?: number; } /** - * Token details for prompt tokens in OpenAI chat completion usage. + * Detailed breakdown of input token usage. */ export interface PromptTokensDetails { /** * Number of tokens retrieved from cache. */ - cached_tokens?: number | null; + cached_tokens?: number; } } } @@ -1114,9 +1124,14 @@ export namespace CompletionListResponse { object?: 'chat.completion'; /** - * Usage information for OpenAI chat completion. + * The service tier that was used for this response. + */ + service_tier?: string | null; + + /** + * Token usage information for the completion. */ - usage?: Data.Usage | null; + usage?: Data.Usage; } export namespace Data { @@ -1674,54 +1689,54 @@ export namespace CompletionListResponse { } /** - * Usage information for OpenAI chat completion. + * Token usage information for the completion. */ export interface Usage { /** * Number of tokens in the completion. */ - completion_tokens: number; + completion_tokens?: number; /** - * Number of tokens in the prompt. + * Detailed breakdown of output token usage. */ - prompt_tokens: number; + completion_tokens_details?: Usage.CompletionTokensDetails; /** - * Total tokens used (prompt + completion). + * Number of tokens in the prompt. */ - total_tokens: number; + prompt_tokens?: number; /** - * Token details for output tokens in OpenAI chat completion usage. + * Detailed breakdown of input token usage. */ - completion_tokens_details?: Usage.CompletionTokensDetails | null; + prompt_tokens_details?: Usage.PromptTokensDetails; /** - * Token details for prompt tokens in OpenAI chat completion usage. + * Total tokens used (prompt + completion). */ - prompt_tokens_details?: Usage.PromptTokensDetails | null; + total_tokens?: number; } export namespace Usage { /** - * Token details for output tokens in OpenAI chat completion usage. + * Detailed breakdown of output token usage. */ export interface CompletionTokensDetails { /** * Number of tokens used for reasoning (o1/o3 models). */ - reasoning_tokens?: number | null; + reasoning_tokens?: number; } /** - * Token details for prompt tokens in OpenAI chat completion usage. + * Detailed breakdown of input token usage. */ export interface PromptTokensDetails { /** * Number of tokens retrieved from cache. */ - cached_tokens?: number | null; + cached_tokens?: number; } } } @@ -1825,6 +1840,11 @@ export interface CompletionCreateParamsBase { */ seed?: number | null; + /** + * The service tier for the request. + */ + service_tier?: 'auto' | 'default' | 'flex' | 'priority' | null; + /** * The stop tokens to use. */ diff --git a/src/resources/responses/responses.ts b/src/resources/responses/responses.ts index b68b4bb..f1e1dbb 100644 --- a/src/resources/responses/responses.ts +++ b/src/resources/responses/responses.ts @@ -111,6 +111,11 @@ export interface ResponseObject { */ error?: ResponseObject.Error | null; + /** + * Details explaining why a response was incomplete. + */ + incomplete_details?: ResponseObject.IncompleteDetails | null; + instructions?: string | null; max_output_tokens?: number | null; @@ -141,6 +146,8 @@ export interface ResponseObject { safety_identifier?: string | null; + service_tier?: string | null; + temperature?: number | null; /** @@ -501,6 +508,13 @@ export namespace ResponseObject { message: string; } + /** + * Details explaining why a response was incomplete. + */ + export interface IncompleteDetails { + reason: string; + } + /** * OpenAI compatible Prompt object that is used in OpenAI responses. */ @@ -2481,6 +2495,11 @@ export interface ResponseListResponse { */ error?: ResponseListResponse.Error | null; + /** + * Details explaining why a response was incomplete. + */ + incomplete_details?: ResponseListResponse.IncompleteDetails | null; + instructions?: string | null; max_output_tokens?: number | null; @@ -2511,6 +2530,8 @@ export interface ResponseListResponse { safety_identifier?: string | null; + service_tier?: string | null; + temperature?: number | null; /** @@ -3404,6 +3425,13 @@ export namespace ResponseListResponse { message: string; } + /** + * Details explaining why a response was incomplete. + */ + export interface IncompleteDetails { + reason: string; + } + /** * OpenAI compatible Prompt object that is used in OpenAI responses. */ @@ -3832,6 +3860,11 @@ export interface ResponseCreateParamsBase { */ safety_identifier?: string | null; + /** + * The service tier for the request. + */ + service_tier?: 'auto' | 'default' | 'flex' | 'priority' | null; + /** * Whether to store the response in the database. */ diff --git a/tests/api-resources/chat/completions.test.ts b/tests/api-resources/chat/completions.test.ts index f3fdd35..10c71b7 100644 --- a/tests/api-resources/chat/completions.test.ts +++ b/tests/api-resources/chat/completions.test.ts @@ -51,6 +51,7 @@ describe('resource completions', () => { response_format: { type: 'text' }, safety_identifier: 'safety_identifier', seed: 0, + service_tier: 'auto', stop: 'string', stream: false, stream_options: { foo: 'bar' }, diff --git a/tests/api-resources/responses/responses.test.ts b/tests/api-resources/responses/responses.test.ts index b68e5cc..fa335d9 100644 --- a/tests/api-resources/responses/responses.test.ts +++ b/tests/api-resources/responses/responses.test.ts @@ -45,6 +45,7 @@ describe('resource responses', () => { prompt_cache_key: 'prompt_cache_key', reasoning: { effort: 'none' }, safety_identifier: 'safety_identifier', + service_tier: 'auto', store: true, stream: false, temperature: 0, From 319853e1691a1086b589dc5e6786c1d2c31043ab Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 05:03:25 +0000 Subject: [PATCH 11/14] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index efd970f..f8aa0b2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-10d6272b97f89f39692d8a734fe1e42de97b2ccc1cd56bc16113d15dff59b8dc.yml -openapi_spec_hash: 69cdb9b6b2edc70ac3c70761a352d992 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-bffd917aa2197580fd7c0a210643e586c4a9658086c7f6559657ea35bd07f855.yml +openapi_spec_hash: cd0e3133ee5fe5b0d6f4fa071cd44cc8 config_hash: 6aa61d4143c3e3df785972c0287d1370 From c7e9581d7df28f5c97dd9ecc903c942f33972649 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 13:59:23 +0000 Subject: [PATCH 12/14] feat: add support for /responses background parameter --- .stats.yml | 4 ++-- src/resources/responses/responses.ts | 10 ++++++++++ tests/api-resources/responses/responses.test.ts | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index f8aa0b2..d0bd27f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-bffd917aa2197580fd7c0a210643e586c4a9658086c7f6559657ea35bd07f855.yml -openapi_spec_hash: cd0e3133ee5fe5b0d6f4fa071cd44cc8 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-373eb8eb3cc02e6f8a9fa33079a5e735886fbf62958ee83e3cdef7bb4c41be37.yml +openapi_spec_hash: fe1fa50161da4f095d128b0de7787e96 config_hash: 6aa61d4143c3e3df785972c0287d1370 diff --git a/src/resources/responses/responses.ts b/src/resources/responses/responses.ts index f1e1dbb..8680b22 100644 --- a/src/resources/responses/responses.ts +++ b/src/resources/responses/responses.ts @@ -104,6 +104,8 @@ export interface ResponseObject { store: boolean; + background?: boolean; + completed_at?: number | null; /** @@ -2488,6 +2490,8 @@ export interface ResponseListResponse { store: boolean; + background?: boolean; + completed_at?: number | null; /** @@ -3780,6 +3784,12 @@ export interface ResponseCreateParamsBase { */ model: string; + /** + * Whether to run the model response in the background. When true, returns + * immediately with status 'queued'. + */ + background?: boolean; + /** * Optional ID of a conversation to add the response to. */ diff --git a/tests/api-resources/responses/responses.test.ts b/tests/api-resources/responses/responses.test.ts index fa335d9..771edaf 100644 --- a/tests/api-resources/responses/responses.test.ts +++ b/tests/api-resources/responses/responses.test.ts @@ -27,6 +27,7 @@ describe('resource responses', () => { const response = await client.responses.create({ input: 'string', model: 'model', + background: true, conversation: 'conversation', guardrails: ['string'], include: ['web_search_call.action.sources'], From abf9c27dcee824cd87f5b1889c456d99a7a94fb9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 17:24:21 +0000 Subject: [PATCH 13/14] feat(vector_io): Implement Contextual Retrieval for improved RAG search quality --- .stats.yml | 4 +- src/resources/vector-stores/file-batches.ts | 57 +++++++++ src/resources/vector-stores/files.ts | 116 ++++++++++++++++++- src/resources/vector-stores/vector-stores.ts | 57 +++++++++ 4 files changed, 231 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index d0bd27f..3573544 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-373eb8eb3cc02e6f8a9fa33079a5e735886fbf62958ee83e3cdef7bb4c41be37.yml -openapi_spec_hash: fe1fa50161da4f095d128b0de7787e96 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-621e8b8ef37d5ebf024fe3bf6a59486a90debf01acca2c9bb4e9032e2dff92d3.yml +openapi_spec_hash: 51f623cd3ea4addf8f939dd4ef8962c8 config_hash: 6aa61d4143c3e3df785972c0287d1370 diff --git a/src/resources/vector-stores/file-batches.ts b/src/resources/vector-stores/file-batches.ts index 0bd7fef..c6edd14 100644 --- a/src/resources/vector-stores/file-batches.ts +++ b/src/resources/vector-stores/file-batches.ts @@ -141,6 +141,7 @@ export interface FileBatchCreateParams { chunking_strategy?: | FileBatchCreateParams.VectorStoreChunkingStrategyAuto | FileBatchCreateParams.VectorStoreChunkingStrategyStatic + | FileBatchCreateParams.VectorStoreChunkingStrategyContextual | null; [k: string]: unknown; @@ -176,6 +177,62 @@ export namespace FileBatchCreateParams { max_chunk_size_tokens?: number; } } + + /** + * Contextual chunking strategy that uses an LLM to situate chunks within the + * document. + */ + export interface VectorStoreChunkingStrategyContextual { + /** + * Configuration for contextual chunking. + */ + contextual: VectorStoreChunkingStrategyContextual.Contextual; + + /** + * Strategy type identifier. + */ + type?: 'contextual'; + } + + export namespace VectorStoreChunkingStrategyContextual { + /** + * Configuration for contextual chunking. + */ + export interface Contextual { + /** + * Tokens to overlap between adjacent chunks. Must be less than + * max_chunk_size_tokens. + */ + chunk_overlap_tokens?: number; + + /** + * Prompt template for contextual retrieval. Uses WHOLE_DOCUMENT and CHUNK_CONTENT + * placeholders wrapped in double curly braces. + */ + context_prompt?: string; + + /** + * Maximum tokens per chunk. Suggested ~700 to allow room for prepended context. + */ + max_chunk_size_tokens?: number; + + /** + * Maximum concurrent LLM calls. Falls back to config default if not provided. + */ + max_concurrency?: number | null; + + /** + * LLM model for generating context. Falls back to + * VectorStoresConfig.contextual_retrieval_params.model if not provided. + */ + model_id?: string | null; + + /** + * Timeout per LLM call in seconds. Falls back to config default if not provided. + */ + timeout_seconds?: number | null; + } + } } export interface FileBatchListFilesParams extends OpenAICursorPageParams { diff --git a/src/resources/vector-stores/files.ts b/src/resources/vector-stores/files.ts index 06b63e0..a4ceebc 100644 --- a/src/resources/vector-stores/files.ts +++ b/src/resources/vector-stores/files.ts @@ -127,7 +127,8 @@ export interface VectorStoreFile { */ chunking_strategy: | VectorStoreFile.VectorStoreChunkingStrategyAuto - | VectorStoreFile.VectorStoreChunkingStrategyStatic; + | VectorStoreFile.VectorStoreChunkingStrategyStatic + | VectorStoreFile.VectorStoreChunkingStrategyContextual; created_at: number; @@ -185,6 +186,62 @@ export namespace VectorStoreFile { } } + /** + * Contextual chunking strategy that uses an LLM to situate chunks within the + * document. + */ + export interface VectorStoreChunkingStrategyContextual { + /** + * Configuration for contextual chunking. + */ + contextual: VectorStoreChunkingStrategyContextual.Contextual; + + /** + * Strategy type identifier. + */ + type?: 'contextual'; + } + + export namespace VectorStoreChunkingStrategyContextual { + /** + * Configuration for contextual chunking. + */ + export interface Contextual { + /** + * Tokens to overlap between adjacent chunks. Must be less than + * max_chunk_size_tokens. + */ + chunk_overlap_tokens?: number; + + /** + * Prompt template for contextual retrieval. Uses WHOLE_DOCUMENT and CHUNK_CONTENT + * placeholders wrapped in double curly braces. + */ + context_prompt?: string; + + /** + * Maximum tokens per chunk. Suggested ~700 to allow room for prepended context. + */ + max_chunk_size_tokens?: number; + + /** + * Maximum concurrent LLM calls. Falls back to config default if not provided. + */ + max_concurrency?: number | null; + + /** + * LLM model for generating context. Falls back to + * VectorStoresConfig.contextual_retrieval_params.model if not provided. + */ + model_id?: string | null; + + /** + * Timeout per LLM call in seconds. Falls back to config default if not provided. + */ + timeout_seconds?: number | null; + } + } + /** * Error information for failed vector store file processing. */ @@ -291,6 +348,7 @@ export interface FileCreateParams { chunking_strategy?: | FileCreateParams.VectorStoreChunkingStrategyAuto | FileCreateParams.VectorStoreChunkingStrategyStatic + | FileCreateParams.VectorStoreChunkingStrategyContextual | null; } @@ -324,6 +382,62 @@ export namespace FileCreateParams { max_chunk_size_tokens?: number; } } + + /** + * Contextual chunking strategy that uses an LLM to situate chunks within the + * document. + */ + export interface VectorStoreChunkingStrategyContextual { + /** + * Configuration for contextual chunking. + */ + contextual: VectorStoreChunkingStrategyContextual.Contextual; + + /** + * Strategy type identifier. + */ + type?: 'contextual'; + } + + export namespace VectorStoreChunkingStrategyContextual { + /** + * Configuration for contextual chunking. + */ + export interface Contextual { + /** + * Tokens to overlap between adjacent chunks. Must be less than + * max_chunk_size_tokens. + */ + chunk_overlap_tokens?: number; + + /** + * Prompt template for contextual retrieval. Uses WHOLE_DOCUMENT and CHUNK_CONTENT + * placeholders wrapped in double curly braces. + */ + context_prompt?: string; + + /** + * Maximum tokens per chunk. Suggested ~700 to allow room for prepended context. + */ + max_chunk_size_tokens?: number; + + /** + * Maximum concurrent LLM calls. Falls back to config default if not provided. + */ + max_concurrency?: number | null; + + /** + * LLM model for generating context. Falls back to + * VectorStoresConfig.contextual_retrieval_params.model if not provided. + */ + model_id?: string | null; + + /** + * Timeout per LLM call in seconds. Falls back to config default if not provided. + */ + timeout_seconds?: number | null; + } + } } export interface FileUpdateParams { diff --git a/src/resources/vector-stores/vector-stores.ts b/src/resources/vector-stores/vector-stores.ts index 06897d2..b1a1a7d 100644 --- a/src/resources/vector-stores/vector-stores.ts +++ b/src/resources/vector-stores/vector-stores.ts @@ -266,6 +266,7 @@ export interface VectorStoreCreateParams { chunking_strategy?: | VectorStoreCreateParams.VectorStoreChunkingStrategyAuto | VectorStoreCreateParams.VectorStoreChunkingStrategyStatic + | VectorStoreCreateParams.VectorStoreChunkingStrategyContextual | null; expires_after?: { [key: string]: unknown } | null; @@ -309,6 +310,62 @@ export namespace VectorStoreCreateParams { max_chunk_size_tokens?: number; } } + + /** + * Contextual chunking strategy that uses an LLM to situate chunks within the + * document. + */ + export interface VectorStoreChunkingStrategyContextual { + /** + * Configuration for contextual chunking. + */ + contextual: VectorStoreChunkingStrategyContextual.Contextual; + + /** + * Strategy type identifier. + */ + type?: 'contextual'; + } + + export namespace VectorStoreChunkingStrategyContextual { + /** + * Configuration for contextual chunking. + */ + export interface Contextual { + /** + * Tokens to overlap between adjacent chunks. Must be less than + * max_chunk_size_tokens. + */ + chunk_overlap_tokens?: number; + + /** + * Prompt template for contextual retrieval. Uses WHOLE_DOCUMENT and CHUNK_CONTENT + * placeholders wrapped in double curly braces. + */ + context_prompt?: string; + + /** + * Maximum tokens per chunk. Suggested ~700 to allow room for prepended context. + */ + max_chunk_size_tokens?: number; + + /** + * Maximum concurrent LLM calls. Falls back to config default if not provided. + */ + max_concurrency?: number | null; + + /** + * LLM model for generating context. Falls back to + * VectorStoresConfig.contextual_retrieval_params.model if not provided. + */ + model_id?: string | null; + + /** + * Timeout per LLM call in seconds. Falls back to config default if not provided. + */ + timeout_seconds?: number | null; + } + } } export interface VectorStoreUpdateParams { From e1ba38df7a75ec5532f3aaf303d5d2e97a9fde5b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 17:24:42 +0000 Subject: [PATCH 14/14] release: 0.5.0-alpha.3 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 29 +++++++++++++++++++++++++++++ package.json | 2 +- src/version.ts | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3c0b29c..44fc7fc 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.5.0-alpha.2" + ".": "0.5.0-alpha.3" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ee4ac0..d4b0979 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # Changelog +## 0.5.0-alpha.3 (2026-02-19) + +Full Changelog: [v0.5.0-alpha.2...v0.5.0-alpha.3](https://github.com/llamastack/llama-stack-client-typescript/compare/v0.5.0-alpha.2...v0.5.0-alpha.3) + +### ⚠ BREAKING CHANGES + +* improve consistency of post-training API endpoints + +### Features + +* Add prompt_cache_key parameter support ([e6399ef](https://github.com/llamastack/llama-stack-client-typescript/commit/e6399ef9e8b34b6cf3238c4c8f8b7d0134a8788e)) +* add support for /responses background parameter ([c7e9581](https://github.com/llamastack/llama-stack-client-typescript/commit/c7e9581d7df28f5c97dd9ecc903c942f33972649)) +* Add truncation parameter support ([3119d6b](https://github.com/llamastack/llama-stack-client-typescript/commit/3119d6bb8a1d38d6fa1958daeed0fb5dbb12b1e1)) +* improve consistency of post-training API endpoints ([93376fc](https://github.com/llamastack/llama-stack-client-typescript/commit/93376fcbe864d4e8becd957301e6df15b3d803f8)) +* **vector_io:** Implement Contextual Retrieval for improved RAG search quality ([abf9c27](https://github.com/llamastack/llama-stack-client-typescript/commit/abf9c27dcee824cd87f5b1889c456d99a7a94fb9)) + + +### Bug Fixes + +* align chat completion usage schema with OpenAI spec ([6fa6eb8](https://github.com/llamastack/llama-stack-client-typescript/commit/6fa6eb87d96902586d4feb82747a5cdf99622045)) +* **inference:** use flat response message model for chat/completions ([d7033cd](https://github.com/llamastack/llama-stack-client-typescript/commit/d7033cd2af32a823514135971b3775037992393c)) +* **vector_io:** align Protocol signatures with request models ([11a1a20](https://github.com/llamastack/llama-stack-client-typescript/commit/11a1a20e82bae62f8210cb26091d3df8bf648f15)) + + +### Chores + +* **api:** minor updates ([1286b39](https://github.com/llamastack/llama-stack-client-typescript/commit/1286b396a69ae48b41ad125405f005264339116d)) +* **internal:** avoid type checking errors with ts-reset ([2cffe20](https://github.com/llamastack/llama-stack-client-typescript/commit/2cffe2040a77c3310db5d1803fc3800b4dd72f28)) + ## 0.5.0-alpha.2 (2026-02-05) Full Changelog: [v0.4.0-alpha.7...v0.5.0-alpha.2](https://github.com/llamastack/llama-stack-client-typescript/compare/v0.4.0-alpha.7...v0.5.0-alpha.2) diff --git a/package.json b/package.json index 22fa765..9cbef4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "llama-stack-client", - "version": "0.5.0-alpha.2", + "version": "0.5.0-alpha.3", "description": "The official TypeScript library for the Llama Stack Client API", "author": "Llama Stack Client ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index 9fbc97f..23b3555 100644 --- a/src/version.ts +++ b/src/version.ts @@ -4,4 +4,4 @@ // This source code is licensed under the terms described in the LICENSE file in // the root directory of this source tree. -export const VERSION = '0.5.0-alpha.2'; // x-release-please-version +export const VERSION = '0.5.0-alpha.3'; // x-release-please-version