Skip to content

How to use structured outputs with Assistants? #542

Closed Answered by davidmigloz
simrat39 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @simrat39,

You have to use ResponseFormat.jsonSchema, like:

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',
                    …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@simrat39
Comment options

@davidmigloz
Comment options

Answer selected by davidmigloz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
p:openai_dart openai_dart package.
2 participants