Skip to content

Commit 6ed1b93

Browse files
authored
feat: Improve type definitions of chat completions response_format parameter (#174)
* feat: Improve type definitions of chat completions response_format parameter * Update openapi.yaml * Update openapi.yaml
1 parent 3249a94 commit 6ed1b93

File tree

1 file changed

+103
-11
lines changed

1 file changed

+103
-11
lines changed

openapi.yaml

Lines changed: 103 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5887,17 +5887,23 @@ components:
58875887
name:
58885888
type: string
58895889
response_format:
5890-
type: object
5891-
description: An object specifying the format that the model must output.
5892-
properties:
5893-
type:
5894-
description: The type of the response format.
5895-
type: string
5896-
example: json
5897-
schema:
5898-
description: The schema of the response format.
5899-
type: object
5900-
additionalProperties: true
5890+
description: |
5891+
An object specifying the format that the model must output.
5892+
5893+
Setting to `{ "type": "json_schema", "json_schema": {...} }` enables
5894+
Structured Outputs which ensures the model will match your supplied JSON
5895+
schema. Learn more in the [Structured Outputs
5896+
guide](https://docs.together.ai/docs/json-mode).
5897+
5898+
Setting to `{ "type": "json_object" }` enables the older JSON mode, which
5899+
ensures the message the model generates is valid JSON. Using `json_schema`
5900+
is preferred for models that support it.
5901+
discriminator:
5902+
propertyName: type
5903+
anyOf:
5904+
- $ref: '#/components/schemas/ResponseFormatText'
5905+
- $ref: '#/components/schemas/ResponseFormatJsonSchema'
5906+
- $ref: '#/components/schemas/ResponseFormatJsonObject'
59015907
tools:
59025908
type: array
59035909
description: A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.
@@ -5919,6 +5925,92 @@ components:
59195925
description: Controls the level of reasoning effort the model should apply when generating responses. Higher values may result in more thoughtful and detailed responses but may take longer to generate.
59205926
example: 'medium'
59215927

5928+
ResponseFormatText:
5929+
type: object
5930+
title: Text
5931+
description: |
5932+
Default response format. Used to generate text responses.
5933+
properties:
5934+
type:
5935+
type: string
5936+
description: The type of response format being defined. Always `text`.
5937+
enum:
5938+
- text
5939+
x-stainless-const: true
5940+
required:
5941+
- type
5942+
ResponseFormatJsonObject:
5943+
type: object
5944+
title: JSON object
5945+
description: |
5946+
JSON object response format. An older method of generating JSON responses.
5947+
Using `json_schema` is recommended for models that support it. Note that the
5948+
model will not generate JSON without a system or user message instructing it
5949+
to do so.
5950+
properties:
5951+
type:
5952+
type: string
5953+
description: The type of response format being defined. Always `json_object`.
5954+
enum:
5955+
- json_object
5956+
x-stainless-const: true
5957+
required:
5958+
- type
5959+
ResponseFormatJsonSchema:
5960+
type: object
5961+
title: JSON schema
5962+
description: |
5963+
JSON Schema response format. Used to generate structured JSON responses.
5964+
Learn more about [Structured Outputs](https://docs.together.ai/docs/json-mode).
5965+
properties:
5966+
type:
5967+
type: string
5968+
description: The type of response format being defined. Always `json_schema`.
5969+
enum:
5970+
- json_schema
5971+
x-stainless-const: true
5972+
json_schema:
5973+
type: object
5974+
title: JSON schema
5975+
description: |
5976+
Structured Outputs configuration options, including a JSON Schema.
5977+
properties:
5978+
description:
5979+
type: string
5980+
description: |
5981+
A description of what the response format is for, used by the model to
5982+
determine how to respond in the format.
5983+
name:
5984+
type: string
5985+
description: |
5986+
The name of the response format. Must be a-z, A-Z, 0-9, or contain
5987+
underscores and dashes, with a maximum length of 64.
5988+
schema:
5989+
$ref: '#/components/schemas/ResponseFormatJsonSchemaSchema'
5990+
strict:
5991+
anyOf:
5992+
- type: boolean
5993+
default: false
5994+
description: |
5995+
Whether to enable strict schema adherence when generating the output.
5996+
If set to true, the model will always follow the exact schema defined
5997+
in the `schema` field. Only a subset of JSON Schema is supported when
5998+
`strict` is `true`. To learn more, read the [Structured Outputs
5999+
guide](https://docs.together.ai/docs/json-mode).
6000+
- type: 'null'
6001+
required:
6002+
- name
6003+
required:
6004+
- type
6005+
- json_schema
6006+
ResponseFormatJsonSchemaSchema:
6007+
type: object
6008+
title: JSON schema
6009+
description: |
6010+
The schema for the response format, described as a JSON Schema object.
6011+
Learn how to build JSON schemas [here](https://json-schema.org/).
6012+
additionalProperties: true
6013+
59226014
ChatCompletionMessageParam:
59236015
oneOf:
59246016
- $ref: '#/components/schemas/ChatCompletionSystemMessageParam'

0 commit comments

Comments
 (0)