How to use structured outputs with Assistants? #542
-
Hi, how do I use the structured outputs (json_schema) mode with the assistants / runs. I tried this but it doesn't seem to be working (unless I'm doing something wrong): RunObject runObject = await _client.createThreadRun(
threadId: _threadObject.id,
request: CreateRunRequest(
assistantId: ...,
responseFormat: const CreateRunRequestResponseFormat.format(
AssistantsResponseFormat(
type: AssistantsResponseFormatType.jsonObject,
),
),
),
); |
Beta Was this translation helpful? Give feedback.
Answered by
davidmigloz
Aug 27, 2024
Replies: 1 comment 2 replies
-
Hey @simrat39, You have to use RunObject runObject = await client.createThreadRun(
threadId: _threadObject.id,
request: CreateRunRequest(
assistantId: ...,
responseFormat: CreateRunRequestResponseFormat.responseFormat(
ResponseFormat.jsonSchema(
jsonSchema: JsonSchemaObject(
name: 'Names',
description: 'A list of names',
strict: true,
schema: {
'type': 'object',
'properties': {
'names': {
'type': 'array',
'items': {
'type': 'string',
},
},
},
'additionalProperties': false,
'required': ['names'],
},
),
),
),
),
); |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
davidmigloz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @simrat39,
You have to use
ResponseFormat.jsonSchema
, like: