Skip to content

How can I use JSON Schema instead of Zod for tools? #5828

Closed Answered by bracesproul
asprouse asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @asprouse! This is actually something we're aiming to standardize in the next few days. Currently, you can pass in JSON schema to most model providers as that's the format they typically require under the hood. This PR (when released) will allow you to pass in tools in OpenAI format to every chat model:

const toolInOpenAIFormat = {
  type: "function",
  function: {
    name: "the name of your tool",
    description: "the tool description",
    parameters: {} // An object containing the JSON schema of the tool.
  }
}

To pass JSON schema to models until that PR is released, you'll need to use the provider specific tool schema. For example, OpenAI uses the above schema, so you'd use it l…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@asprouse
Comment options

@dosubot
Comment options

@asprouse
Comment options

Comment options

You must be logged in to vote
3 replies
@asprouse
Comment options

@bracesproul
Comment options

@asprouse
Comment options

Answer selected by bracesproul
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants