Find answers from the community

Updated 2 days ago

Schema

hello there, i have a question about token cost when using structured output. when i provide my own pydantic class during inference, does the schema itself (without text generated by the llm) cost any tokens when the llm generates the whole structured output?

Based on the example below, does outputting the schema structure (e.g. the keys - "car_brands", "brand", "country", parenthesis, commas, etc.) also cost any tokens? Or the cost are solely on the values ("Toyota", "Japan", 1937, etc) that the llm generates? Thanks!

Plain Text
{
  "car_brands": [
    {
      "brand": "Toyota",
      "country": "Japan",
      "founded": 1937
    },
    {
      "brand": "BMW",
      "country": "Germany",
      "founded": 1916
    },
    {
      "brand": "Ford",
      "country": "USA",
      "founded": 1903
    }
  ]
}
L
2 comments
The schema counts towards input tokens yes
And the generated tool/function selection also counts
Add a reply
Sign up and join the conversation on Discord