I am unable to get structred outputs working using the openai python library, with openrouter as the backend and anthropic/claude-3-opus:beta as the selected model
it just responds in plain text, causing the structured output parsing to fail, whereas if I switch the model to gpt4o, structured outputs work
according to the openrouter website, anthropic/claude-3.5-sonnet:beta should support tool calling
#Structured outputs with anthropic/claude-3.5-sonnet:beta not working
1 messages · Page 1 of 1 (latest)
Can you share your prompt
hi, you can't use the structured output feature with anthropic/claude-3.5-sonnet:beta yet (the upstream doesn't support the similar schema / method overall). it's only available for openai models.
why does the openrouter website say that claude3.5 supports tool calling then?
is anthropic tool calling via openrouter incompatible with the openai python module due to anthropic using a different tool calling interface to openai?
tool calling and structured output is partially different features.
claude 3.5 supports tool calling as you've mentioned, however it does not allow you to specify output types or schema (using zod or pydantic)
you can check our docs on tool calling:
https://openrouter.ai/docs/requests#tool-calls
ah ok thx I see.
in the context of openai models, is it recommended to use tool calling whenever using structured outputs? or can structured outputs be used independently?
no, you can use structured outputs without calling tools:
https://platform.openai.com/docs/guides/structured-outputs/introduction