Skip to content

structured output support #16

@markacianfrani

Description

@markacianfrani

Steps to reproduce:

import { generateObject } from "ai";
// @ts-ignore
import { githubModels } from "@github/models";
import { z } from "zod";

const { object } = await generateObject({
  model: githubModels("openai/gpt-4o-mini"),
  schema: z.object({
    name: z.string(),
    age: z.number(),
  }),
  prompt: "Generate a person",
});

console.log(object);

The SDK has a nice abstraction around structured outputs but they don't currently work with compatible models.

Fix is very simple: just add supportsStructuredOutput to the provider. However, the hard part is that not all GitHub Models support it. and there's no metadata that I know of that can tell us which ones do and which ones don't

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions