Get the LLM to adhere to your JSON schema using Anyscale & Together AI’s newly introduced JSON modes
LLMs excel at generating creative text, but production applications demand structured outputs for seamless integration. Instructing LLMs to only generate the output in a specified syntax can help make their behaviour a bit more predictable. JSON is the format of choice here - it is versatile enough and is widely used as a standard data exchange format.Several LLM providers offer features that help enforce JSON outputs:
OpenAI has a feature called JSON mode that ensures that the output is a valid JSON object.
While this is great, it doesn’t guarantee adherence to your custom JSON schemas, but only that the output IS a JSON.
Anyscale and Together AI go further - they not only enforce that the output is in JSON but also ensure that the output follows any given JSON schema.
Using Portkey, you can easily experiment with models from Anyscale & Together AI and explore the power of their JSON modes:
import Portkey from 'portkey-ai';const portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", provider: "@anyscale-prod" // Or "@together-prod"})async function main() { const json_response = await portkey.chat.completions.create({ messages: [{role: "user", content: "Give me a recipe for making Ramen, in JSON format"}], model: "mistralai/Mistral-7B-Instruct-v0.1", response_format: { type: "json_object", schema: { type: "object", properties: { title: {type: "string"}, description: {type: "string"}, steps: {type: "array"} } } } }); console.log(json_response.choices[0].message.content);}main()
from portkey_ai import Portkeyfrom pydantic import BaseModelfrom typing import Listportkey = Portkey( api_key="PORTKEY_API_KEY", provider="@anyscale-prod" # Or "@together-prod")class Recipe(BaseModel): title: str description: str steps: List[str]json_response = portkey.chat.completions.create( messages=[{"role": "user", "content": "Give me a recipe for making Ramen, in JSON format"}], model="mistralai/Mistral-7B-Instruct-v0.1", response_format={"type": "json_object", "schema": Recipe.schema_json()})print(json_response.choices[0].message.content)
{ "title": "Fried Rice with Chicken and Vegetables", "description": "A delicious recipe for fried rice that includes chicken and a mix of colorful vegetables. Perfect for a healthy and satisfying meal. yum yum yum yum yum", "steps": [ "1. Cook rice and set aside", "2. In a large skillet or wok, sauté sliced chicken in oil until browned", "3. ..." ]}
As you can see - it’s pretty simple. Just define the JSON schema, and pass it at the time of making your request using the response_format param. The response_format’s type is json_object and the schema contains all keys and their expected type.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Portkey (Prisma AIRS AI Gateway) Docs","description":"Comprehensive documentation for AI Gateway, Guardrails, Observability, and Governance features.","colors":{"primary":"#0891B2","light":"#0891B2","dark":"#0891B2"},"logo":{"light":"https://mintcdn.com/portkey-docs/tHk-hgNjLbEj4dhh/images/portkey-PANW-company-logo-positive.png?fit=max\u0026auto=format\u0026n=tHk-hgNjLbEj4dhh\u0026q=85\u0026s=c5fb09014ff79616583b1d3bffe27450","dark":"https://mintcdn.com/portkey-docs/tHk-hgNjLbEj4dhh/images/portkey-PANW-company-logo-negative.png?fit=max\u0026auto=format\u0026n=tHk-hgNjLbEj4dhh\u0026q=85\u0026s=6025ca49ef544522f58ff471b7f75f8f"},"favicon":"https://mintcdn.com/portkey-docs/Hf1XgyjG_b79ym4Q/favicon.png?fit=max\u0026auto=format\u0026n=Hf1XgyjG_b79ym4Q\u0026q=85\u0026s=cbaa1bfc49bb6e3fd6cf499a5da313a3","api":{"openapi":"https://raw.githubusercontent.com/Portkey-AI/openapi/refs/heads/master/openapi.yaml","examples":{"prefill":true},"url":"full"},"navbar":{"links":[{"href":"https://portkey.ai/models","label":"Models"},{"href":"https://support.portkey.ai/forms/customer-portal-ticket-form","label":"Support"},{"href":"https://www.paloaltonetworks.in/ai-security/ai-gateway?utm_source=portkey\u0026utm_medium=referral\u0026utm_campaign=prisma_airs\u0026utm_content=docs_nav#contact","label":"Contact Us"}],"primary":{"type":"button","label":"Sign in","href":"https://stratacloudmanager.paloaltonetworks.com/"}},"footer":{"socials":{"x":"https://twitter.com/PortkeyAI","linkedin":"https://www.linkedin.com/company/portkey-ai","github":"https://git.new/portkey"},"links":[{"header":"For LLMs","items":[{"label":"llms.txt","href":"https://portkey.ai/docs/llms.txt"},{"label":"llms-full.txt","href":"https://portkey.ai/docs/llms-full.txt"}]},{"header":"Products","items":[{"label":"Observability","href":"https://portkey.ai/features/observability"},{"label":"AI Gateway","href":"https://portkey.ai/features/ai-gateway"},{"label":"Guardrails","href":"https://portkey.ai/features/guardrails"},{"label":"Prompt Management","href":"https://portkey.ai/features/prompt-management"},{"label":"Agents","href":"https://portkey.ai/features/agents"},{"label":"MCP Gateway","href":"https://portkey.ai/docs/product/mcp-gateway"},{"label":"Security","href":"https://portkey.ai/features/security-and-compliance"},{"label":"Auto-Instrumentation","href":"https://portkey.ai/features/auto-instrumentation"}]},{"header":"Resources","items":[{"label":"API Status","href":"https://status.portkey.ai/"},{"label":"Helm Charts","href":"https://github.com/portkey-ai/helm"},{"label":"AI Grants Finder","href":"https://grantsfinder.portkey.ai/"},{"label":"Events Calendar","href":"https://lu.ma/portkey"},{"label":"Blog","href":"https://portkey.ai/blog"},{"label":"Error Library","href":"https://portkey.ai/error-library"},{"label":"Models \u0026 Pricing","href":"https://portkey.ai/models"}]},{"header":"Company","items":[{"label":"Pricing","href":"https://portkey.ai/pricing"},{"label":"Compliances","href":"https://trust.portkey.ai/"},{"label":"Privacy Policy","href":"https://portkey.ai/privacy-policy"},{"label":"Terms of Service","href":"https://portkey.ai/terms"},{"label":"DPA","href":"https://portkey.ai/dpa"},{"label":"Cookie Policy","href":"https://portkey.ai/cookie-policy"}]}]},"seo":{"metatags":{"og:type":"website","og:site_name":"Portkey AI Gateway Docs"},"indexing":"navigable"},"styling":{"eyebrows":"breadcrumbs","codeblocks":"system","latex":true},"integrations":{"ga4":{"measurementId":"G-JJMXYE4DRL"}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"toc"},"interaction":{"drilldown":true},"metadata":{"timestamp":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"portkey-docs","hasAudioNarration":false,"actualSubdomain":"portkey-docs","customDomains":["docs.portkey.ai","portkey.ai"],"gitSource":{"type":"github","owner":"portkey-ai","repo":"docs-core","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"feedback":{"thumbs":true,"edits":true,"issues":true,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"DISABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"DISABLED"}},"buildId":"6aedd8f11fad4dc685c6fc14","clientVersion":"0.0.4087","searchFilterCounts":[{"language":"default","tag":"Integrations","count":699},{"language":"default","tag":"Product","count":386},{"language":"default","tag":"Docs","count":324},{"language":"default","tag":"LLM Integrations","count":307},{"language":"default","tag":"Admin APIs","count":189},{"language":"default","tag":"More","count":176},{"language":"default","tag":"Guardrails","count":102},{"language":"default","tag":"Administration","count":102},{"language":"default","tag":"AI Gateway","count":99},{"language":"default","tag":"Admin API","count":95}],"searchSettings":{"isFiltersEnabled":true,"showContentSnippets":true}},"assistantConfig":{"enableAskAiButton":true,"enableStarterQuestions":true,"enableContextualStarterQuestions":true,"enableAskAiSearchBar":true,"deflection":{"enabled":true,"email":"support@portkey.ai","showHelpButton":true}},"basePath":"/docs","hasChatPermissions":false,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"comment-mode","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"#banner{background:linear-gradient(90deg, #0d1b2e 0%, #1a1040 40%, #2d0f22 100%);border-bottom:1px solid rgba(255, 255, 255, 0.08)}#banner a{color:#f0f0f0;text-decoration:none;font-weight:600;border-bottom:1px solid rgba(240, 240, 240, 0.5);padding-bottom:1px;transition:border-color 0.2s ease}#banner a:hover{border-bottom-color:#ffffff}"}],"page":{"pagePath":"guides/use-cases/enforcing-json-schema-with-anyscale-and-together","slug":"/guides/use-cases/enforcing-json-schema-with-anyscale-and-together","pageMetadata":{"title":"Enforcing JSON Schema with Anyscale \u0026 Together","description":"Get the LLM to adhere to your JSON schema using Anyscale \u0026 Together AI's newly introduced JSON modes","href":"/guides/use-cases/enforcing-json-schema-with-anyscale-and-together"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Get the LLM to adhere to your JSON schema using Anyscale \u0026 Together AI’s newly introduced JSON modes\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,hr:`hr`,li:`li`,p:`p`,pre:`pre`,span:`span`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{Card,CodeBlock,CodeGroup,Heading,Icon,Table}=_components;if(!Card)_missingMdxReference(`Card`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Icon)_missingMdxReference(`Icon`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`LLMs excel at generating creative text, but production applications demand structured outputs for seamless integration. Instructing LLMs to only generate the output in a specified syntax can help make their behaviour a bit more predictable. JSON is the format of choice here - it is versatile enough and is widely used as a standard data exchange format.`}),`\n`,_jsx(_components.p,{children:`Several LLM providers offer features that help enforce JSON outputs:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`OpenAI has a feature called `,_jsx(_components.a,{href:`https://platform.openai.com/docs/guides/text-generation/json-mode`,children:`JSON mode`}),` that ensures that the output is a valid JSON object.`]}),`\n`,_jsx(_components.li,{children:`While this is great, it doesn’t guarantee adherence to your custom JSON schemas, but only that the output IS a JSON.`}),`\n`,_jsx(_components.li,{children:`Anyscale and Together AI go further - they not only enforce that the output is in JSON but also ensure that the output follows any given JSON schema.`}),`\n`]}),`\n`,_jsx(_components.p,{children:`Using Portkey, you can easily experiment with models from Anyscale \u0026 Together AI and explore the power of their JSON modes:`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`JavaScript`,icon:`square-js`,numberOfLines:`27`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`27`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Portkey`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'portkey-ai'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` portkey`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Portkey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` apiKey:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"PORTKEY_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` provider:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@anyscale-prod\"`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Or \"@together-prod\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` main`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` json_response`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` portkey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`completions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` messages:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`role:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Give me a recipe for making Ramen, in JSON format\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` model:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"mistralai/Mistral-7B-Instruct-v0.1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` response_format:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` type:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"json_object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` schema:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` type:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` properties:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` title:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`type:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` description:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`type:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` steps:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`type:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"array\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`json_response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`choices`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`main`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Python`,icon:`python`,numberOfLines:`21`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`21`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` portkey_ai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Portkey`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` pydantic `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` BaseModel`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` typing `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` List`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`portkey `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Portkey(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"PORTKEY_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` provider`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"@anyscale-prod\"`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Or \"@together-prod\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Recipe`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`BaseModel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` title: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` description: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` steps: List[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`json_response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` portkey.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Give me a recipe for making Ramen, in JSON format\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"mistralai/Mistral-7B-Instruct-v0.1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` response_format`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"json_object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"schema\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: Recipe.schema_json()}`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(json_response.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].message.content)`})]}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`3`,id:`output-json`,children:`Output JSON:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`10`,children:[_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"title\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Fried Rice with Chicken and Vegetables\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"description\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"A delicious recipe for fried rice that includes chicken and a mix of colorful vegetables. Perfect for a healthy and satisfying meal. yum yum yum yum yum\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"steps\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"1. Cook rice and set aside\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"2. In a large skillet or wok, sauté sliced chicken in oil until browned\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"3. ...\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`As you can see - it’s pretty simple. Just define the JSON schema, and pass it at the time of making your request using the `,_jsx(_components.code,{children:`response_format`}),` param. The `,_jsx(_components.code,{children:`response_format`}),`’s `,_jsx(_components.code,{children:`type`}),` is `,_jsx(_components.code,{children:`json_object`}),` and the `,_jsx(_components.code,{children:`schema`}),` contains all keys and their expected type.`]}),`\n`,_jsx(Heading,{level:`2`,id:`supporting-models`,children:`Supporting Models`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Model/Provider`}),_jsx(_components.th,{children:`Ensure JSON`}),_jsx(_components.th,{children:`Ensure Schema`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`mistralai/Mistral-7B-Instruct-v0.1 Anyscale`}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`mistralai/Mixtral-8x7B-Instruct-v0.1Anyscale`}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`mistralai/Mixtral-8x7B-Instruct-v0.1Together AI`}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`mistralai/Mistral-7B-Instruct-v0.1Together AI`}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`togethercomputer/CodeLlama-34b-InstructTogether AI`}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`gpt-4 and previous releases OpenAI / Azure OpenAI`}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})}),_jsx(_components.td,{children:_jsx(Icon,{icon:`xmark`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`gpt-3.5-turbo and previous releases OpenAI / Azure OpenAI`}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})}),_jsx(_components.td,{children:_jsx(Icon,{icon:`xmark`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Ollama models`}),_jsx(_components.td,{children:_jsx(Icon,{icon:`square-check`})}),_jsx(_components.td,{children:_jsx(Icon,{icon:`xmark`})})]})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`creating-nested-json-object-schema`,children:`Creating Nested JSON Object Schema`}),`\n`,_jsx(_components.p,{children:`Here’s an example showing how you can also create nested JSON schema and get the LLM to enforce it:`}),`\n`,_jsx(CodeBlock,{filename:`Python`,icon:`python`,numberOfLines:`15`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`15`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Ingredient`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`BaseModel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` name: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` quantity: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Recipe`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`BaseModel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` title: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` description: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ingredients: List[Ingredient]`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` steps: List[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`json_response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` portkey.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Give me a recipe for making Ramen, in JSON format\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"mistralai/Mistral-7B-Instruct-v0.1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` response_format`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"json_object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"schema\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: Recipe.schema_json()}`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Add your Anyscale or Together AI credentials to `,_jsx(_components.a,{href:`https://app.portkey.ai/model-catalog`,children:`Model Catalog`}),` and get started!`]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Card,{title:`Portkey is now PRISMA AIRS AI Gateway. See it in action.`,href:`https://www.paloaltonetworks.in/ai-security/ai-gateway?utm_source=portkey\u0026utm_medium=referral\u0026utm_campaign=prisma_airs\u0026utm_content=docs_nav#contact`,icon:`arrow-up-right-from-square`,children:_jsx(_components.p,{children:`Contact Us`})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":"system","config":{},"pageMetadata":{"title":"Enforcing JSON Schema with Anyscale \u0026 Together","description":"Get the LLM to adhere to your JSON schema using Anyscale \u0026 Together AI's newly introduced JSON modes","href":"/guides/use-cases/enforcing-json-schema-with-anyscale-and-together"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Output JSON:","slug":"output-json","depth":3,"children":[]},{"title":"Supporting Models","slug":"supporting-models","depth":2,"children":[{"title":"Creating Nested JSON Object Schema","slug":"creating-nested-json-object-schema","depth":3,"children":[]}]}],"codeExamples":{}},"jsLinks":[],"subdomain":"portkey-docs","siteName":"Portkey (Prisma AIRS AI Gateway) Docs","title":"Enforcing JSON Schema with Anyscale \u0026 Together - Portkey (Prisma AIRS AI Gateway) Docs","relatedPagesConfig":{"enabled":true,"limit":5,"mode":"automatic"},"contextualStarterQuestions":[{"_id":"6aa971c40031bd0287c968ea","deploymentId":"67086365a151447bf2fa5021","questionText":"Which providers support JSON modes?","status":"active","generatedBy":"contextual","path":"guides/use-cases/enforcing-json-schema-with-anyscale-and-together","createdAt":"2026-09-15T16:26:44.446Z","updatedAt":"2026-09-15T16:26:44.446Z","__v":0},{"_id":"6aa971c40031bd0287c968eb","deploymentId":"67086365a151447bf2fa5021","questionText":"How do I use Portkey with Anyscale?","status":"active","generatedBy":"contextual","path":"guides/use-cases/enforcing-json-schema-with-anyscale-and-together","createdAt":"2026-09-15T16:26:44.446Z","updatedAt":"2026-09-15T16:26:44.446Z","__v":0},{"_id":"6aa971c40031bd0287c968e9","deploymentId":"67086365a151447bf2fa5021","questionText":"How do I enforce JSON schemas?","status":"active","generatedBy":"contextual","path":"guides/use-cases/enforcing-json-schema-with-anyscale-and-together","createdAt":"2026-09-15T16:26:44.446Z","updatedAt":"2026-09-15T16:26:44.446Z","__v":0}],"navMaps":{"firstHrefInVersion":{"Latest":{"href":"/guides/use-cases/enforcing-json-schema-with-anyscale-and-together","matchLevel":0},"Prisma AIRS":{"href":"/aigw/introduction/welcome","matchLevel":4},"Virtual Keys (Deprecated)":{"href":"/guides/use-cases/enforcing-json-schema-with-anyscale-and-together","matchLevel":0}},"firstHrefInLanguage":{}},"lastModified":"2026-08-10T11:57:33.590Z","gitLastModified":"2026-08-06T05:55:04.000Z","originalFileLocation":"guides/use-cases/enforcing-json-schema-with-anyscale-and-together.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Get the LLM to adhere to your JSON schema using Anyscale \u0026amp; Together AI\u0026#x27;s newly introduced JSON modes\">\u003cmeta data-mint-head name=\"application-name\" content=\"Portkey (Prisma AIRS AI Gateway) Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/portkey-docs/9Whrk-8bCE6hyGSn/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/portkey-docs/9Whrk-8bCE6hyGSn/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/portkey-docs/9Whrk-8bCE6hyGSn/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/portkey-docs/9Whrk-8bCE6hyGSn/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/portkey-docs/9Whrk-8bCE6hyGSn/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/portkey-docs/9Whrk-8bCE6hyGSn/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/portkey-docs/9Whrk-8bCE6hyGSn/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/portkey-docs/9Whrk-8bCE6hyGSn/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/portkey-docs/9Whrk-8bCE6hyGSn/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Enforcing JSON Schema with Anyscale \u0026amp; Together - Portkey (Prisma AIRS AI Gateway) Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Get the LLM to adhere to your JSON schema using Anyscale \u0026amp; Together AI\u0026#x27;s newly introduced JSON modes\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Portkey AI Gateway Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.portkey.ai/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://portkey-docs.mintlify.site/docs/_mintlify/api/og/v2?division=Use+Cases\u0026amp;title=Enforcing+JSON+Schema+with+Anyscale+%26+Together\u0026amp;description=Get+the+LLM+to+adhere+to+your+JSON+schema+using+Anyscale+%26+Together+AI%27s+newly+introduced+JSON+modes\u0026amp;theme=262137c9f2583e48984715e7\u0026amp;signature=70fc05edb02823a39d32587dc0798cd1c5d587ea7517cefdbbbeaf4f3d8861cf\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Enforcing JSON Schema with Anyscale \u0026amp; Together - Portkey (Prisma AIRS AI Gateway) Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Get the LLM to adhere to your JSON schema using Anyscale \u0026amp; Together AI\u0026#x27;s newly introduced JSON modes\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://portkey-docs.mintlify.site/docs/_mintlify/api/og/v2?division=Use+Cases\u0026amp;title=Enforcing+JSON+Schema+with+Anyscale+%26+Together\u0026amp;description=Get+the+LLM+to+adhere+to+your+JSON+schema+using+Anyscale+%26+Together+AI%27s+newly+introduced+JSON+modes\u0026amp;theme=262137c9f2583e48984715e7\u0026amp;signature=70fc05edb02823a39d32587dc0798cd1c5d587ea7517cefdbbbeaf4f3d8861cf\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/portkey-docs/9Whrk-8bCE6hyGSn/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Portkey (Prisma AIRS AI Gateway) Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0891B2\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.portkey.ai/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.portkey.ai/#organization\",\"name\":\"Portkey (Prisma AIRS AI Gateway) Docs\",\"url\":\"https://docs.portkey.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/portkey-docs/tHk-hgNjLbEj4dhh/images/portkey-PANW-company-logo-positive.png?fit=max\u0026auto=format\u0026n=tHk-hgNjLbEj4dhh\u0026q=85\u0026s=c5fb09014ff79616583b1d3bffe27450\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.portkey.ai/docs#website\",\"name\":\"Portkey (Prisma AIRS AI Gateway) Docs\",\"url\":\"https://docs.portkey.ai/docs\",\"publisher\":{\"@id\":\"https://docs.portkey.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.portkey.ai/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together#webpage\",\"url\":\"https://docs.portkey.ai/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together\",\"name\":\"Enforcing JSON Schema with Anyscale \u0026 Together\",\"description\":\"Get the LLM to adhere to your JSON schema using Anyscale \u0026 Together AI's newly introduced JSON modes\",\"dateModified\":\"2026-08-06T05:55:04.000Z\",\"isPartOf\":{\"@id\":\"https://docs.portkey.ai/docs#website\"},\"breadcrumb\":{\"@id\":\"https://docs.portkey.ai/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.portkey.ai/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Use Cases\",\"item\":\"https://docs.portkey.ai/docs/guides/use-cases\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Enforcing JSON Schema with Anyscale \u0026 Together\",\"item\":\"https://docs.portkey.ai/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.portkey.ai/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together#article\",\"headline\":\"Enforcing JSON Schema with Anyscale \u0026 Together\",\"name\":\"Enforcing JSON Schema with Anyscale \u0026 Together\",\"description\":\"Get the LLM to adhere to your JSON schema using Anyscale \u0026 Together AI's newly introduced JSON modes\",\"url\":\"https://docs.portkey.ai/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together\",\"mainEntityOfPage\":{\"@id\":\"https://docs.portkey.ai/docs/guides/use-cases/enforcing-json-schema-with-anyscale-and-together#webpage\"},\"dateModified\":\"2026-08-06T05:55:04.000Z\",\"publisher\":{\"@id\":\"https://docs.portkey.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.portkey.ai/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Portkey (Prisma AIRS AI Gateway) Docs\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Portkey (Prisma AIRS AI Gateway) Docs","nav":{"global":null,"versions":[{"version":"Latest","tabs":[{"tab":"Docs","pages":[{"title":"Docs","href":"/introduction/what-is-portkey"}]},{"tab":"Integrations","pages":[{"title":"Integrations","href":"/integrations/ecosystem"}]},{"tab":"Gateway APIs","pages":[{"title":"Gateway APIs","href":"/api-reference/inference-api/introduction"}]},{"tab":"Admin APIs","pages":[{"title":"Admin APIs","href":"/api-reference/admin-api/introduction"}]},{"tab":"Cookbooks","groups":[{"group":"Evals","pages":[{"title":"How to Run Structured Output Evals at Scale","href":"/guides/use-cases/run-batch-evals"},{"title":"Building an LLM-as-a-Judge System for AI (Customer Support) Agent","href":"/guides/prompts/llm-as-a-judge"}]},{"group":"Prompt Engineering","pages":[{"title":null,"href":"/guides/prompts"},{"title":"Ultimate AI SDR","href":"/guides/prompts/ultimate-ai-sdr"},{"title":"Build a chatbot using Portkey's Prompt Templates","href":"/guides/prompts/build-a-chatbot-using-portkeys-prompt-templates"},{"title":"Building an LLM-as-a-Judge System for AI (Customer Support) Agent","href":"/guides/prompts/llm-as-a-judge"},{"title":"Optimizing Prompts for Customer Support using Portkey | LLama Prompt Ops Integration","href":"/guides/prompts/llama-prompts"}]},{"group":"Whitepapers","pages":[{"group":"Optimizing LLM Costs","pages":[{"title":"Executive Summary","href":"/guides/whitepapers/optimizing-llm-costs/executive-summary"},{"title":"1. Introduction","href":"/guides/whitepapers/optimizing-llm-costs/introduction"},{"title":"2. Understanding LLM Cost Drivers","href":"/guides/whitepapers/optimizing-llm-costs/llm-cost-drivers"},{"title":"3. FrugalGPT Techniques for Cost Optimization","href":"/guides/whitepapers/optimizing-llm-costs/frugalgpt-techniques"},{"title":"4. Advanced Strategies for Performance Improvement","href":"/guides/whitepapers/optimizing-llm-costs/advanced-strategies"},{"title":"5. Architectural Considerations","href":"/guides/whitepapers/optimizing-llm-costs/architectural-considerations"},{"title":"6. Operational Best Pracitces","href":"/guides/whitepapers/optimizing-llm-costs/operational-best-practices"},{"title":"7. Cost Effective Development Practices","href":"/guides/whitepapers/optimizing-llm-costs/cost-effective-development"},{"title":"8. User Education and Change Management","href":"/guides/whitepapers/optimizing-llm-costs/user-education"},{"title":"9. Future Trends in LLM Cost Optimization","href":"/guides/whitepapers/optimizing-llm-costs/future-trends"},{"title":"10. Conclusion and Key Takeaways","href":"/guides/whitepapers/optimizing-llm-costs/conclusion-and-key-takeaways"}]}]},{"group":"Getting Started","pages":[{"title":"Overview","href":"/guides/getting-started"},{"title":"A/B Test Prompts and Models","href":"/guides/getting-started/a-b-test-prompts-and-models"},{"title":"Tackling Rate Limiting","href":"/guides/getting-started/tackling-rate-limiting"},{"title":"Function Calling","href":"/guides/getting-started/function-calling"},{"title":"Image Generation","href":"/guides/getting-started/image-generation"},{"title":"Getting Started with AI Gateway","href":"/guides/getting-started/getting-started-with-ai-gateway"},{"title":"Llama 3 on Groq","href":"/guides/getting-started/llama-3-on-groq"},{"title":"Return Repeat Requests from Cache","href":"/guides/getting-started/return-repeat-requests-from-cache"},{"title":"Trigger Automatic Retries on LLM Failures","href":"/guides/getting-started/trigger-automatic-retries-on-llm-failures"},{"title":"101 on Portkey's Gateway Configs","href":"/guides/getting-started/101-on-portkey-s-gateway-configs"}]},{"group":"Integrations","pages":[{"title":"Overview","href":"/guides/integrations"},{"title":"Portkey CLI","href":"/guides/coding-agents/agent-cli"},{"title":"Skills Registry","href":"/guides/coding-agents/skills"},{"title":"Llama 3 on Portkey + Together AI","href":"/guides/integrations/llama-3-on-portkey-+-together-ai"},{"title":"Introduction to GPT-4o","href":"/guides/integrations/introduction-to-gpt-4o"},{"title":"Anyscale","href":"/guides/integrations/anyscale"},{"title":"Mistral","href":"/guides/integrations/mistral"},{"title":"Vercel AI","href":"/guides/integrations/vercel-ai"},{"title":"Deepinfra","href":"/guides/integrations/deepinfra"},{"title":"Groq","href":"/guides/integrations/groq"},{"title":"Langchain","href":"/guides/integrations/langchain"},{"title":"Mixtral 8x22b","href":"/guides/integrations/mixtral-8x22b"},{"title":"Segmind","href":"/guides/integrations/segmind"},{"title":"Sync Open WebUI Feedback → Portkey","href":"/guides/integrations/openwebui-to-portkey"}]},{"group":"Use Cases","pages":[{"title":"Overview","href":"/guides/use-cases"},{"title":"Unified LLM API with Automatic Failover \u0026 Error Handling","href":"/guides/use-cases/enterprise-ready-unified-api"},{"title":"Multi-Tenant LLM Access with Enterprise Control for Customer-Facing Apps","href":"/guides/use-cases/multi-tenant-ai-feature"},{"title":"Enforcing Budget, Token \u0026 Rate Limits: Use Cases","href":"/guides/use-cases/enforcing-limits-and-budgets"},{"title":"Testing Application Resilience with Fallbacks","href":"/guides/use-cases/fallbacks-test"},{"title":"How to use Portkey Guardrails for PII Protection","href":"/guides/use-cases/guardrail-pii-use-case"},{"title":"Creating your own partner guardrails","href":"/guides/use-cases/creating-partner-guardrails"},{"title":"Handle streaming output guardrails for client-side decisions","href":"/guides/use-cases/streaming-output-guardrails"},{"title":"Web Search for Any LLM in LibreChat","href":"/guides/use-cases/librechat-web-search"},{"title":"Few-Shot Prompting","description":"LLMs are highly capable of following a given structure. By providing a few examples of how the assistant should respond to a given prompt, the LLM can generate responses that closely follow the format of these examples.","href":"/guides/use-cases/few-shot-prompting"},{"title":"Enforcing JSON Schema with Anyscale \u0026 Together","href":"/guides/use-cases/enforcing-json-schema-with-anyscale-and-together"},{"title":"Detecting Emotions with GPT-4o","description":null,"href":"/guides/use-cases/emotions-with-gpt-4o"},{"title":"Build an article suggestion app with Supabase pgvector, and Portkey","href":"/guides/use-cases/build-an-article-suggestion-app-with-supabase-pgvector-and-portkey"},{"title":"Setting up resilient Load balancers with failure-mitigating Fallbacks","href":"/guides/use-cases/setting-up-resilient-load-balancers-with-failure-mitigating-fallbacks"},{"title":"Combining Routing Strategies: Conditional, Load Balancing \u0026 Fallbacks","href":"/guides/use-cases/combining-routing-strategies"},{"title":"Run Portkey on Prompts from Langchain Hub","href":"/guides/use-cases/run-portkey-on-prompts-from-langchain-hub"},{"title":"Smart Fallback with Model-Optimized Prompts","href":"/guides/use-cases/smart-fallback-with-model-optimized-prompts"},{"title":"How to use OpenAI SDK with Portkey Prompt Templates","href":"/guides/use-cases/how-to-use-openai-sdk-with-portkey-prompt-templates"},{"title":"Setup OpenAI -> Azure OpenAI Fallback","href":"/guides/use-cases/setup-openai-greater-than-azure-openai-fallback"},{"title":"Fallback from SDXL to Dall-e-3","href":"/guides/use-cases/fallback-from-sdxl-to-dall-e-3"},{"title":"Comparing Top10 LMSYS Models with Portkey","href":"/guides/use-cases/comparing-top10-lmsys-models-with-portkey"},{"title":"Request metadata use cases","href":"/guides/use-cases/metadata-use-cases"},{"title":"Tracking LLM Costs Per User with Portkey","href":"/guides/use-cases/track-costs-using-metadata"},{"title":"Comparing DeepSeek Models Against OpenAI, Anthropic \u0026 More Using Portkey","href":"/guides/use-cases/deepseek-r1"},{"title":"Portkey with OpenAI Computer Use","href":"/guides/use-cases/openai-computer-use"},{"title":"Using Private MCP Servers with Responses API","href":"/guides/use-cases/private-mcp-servers"},{"title":"Converting STDIO to Remote MCP Servers","icon":"globe","href":"/guides/converting-stdio-to-streamable-http"}]}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog/2026/september"}]},{"tab":"Help Center","pages":[{"title":"Help Center","href":"/help-center/you-do-not-have-enough-permissions"}]}]},{"version":"Prisma AIRS","pages":[{"title":"Prisma AIRS","href":"/aigw/introduction/welcome"}]},{"version":"Virtual Keys (Deprecated)","tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":"/virtual_key_old/introduction/what-is-portkey"}]},{"tab":"Integrations","pages":[{"title":"Integrations","href":"/virtual_key_old/integrations/ecosystem"}]},{"tab":"Inference API","pages":[{"title":"Inference API","href":"/api-reference/inference-api/introduction"}]},{"tab":"Admin API","pages":[{"title":"Admin API","href":"/api-reference/admin-api/introduction"}]},{"tab":"Cookbooks","groups":[{"group":"Evals","pages":[{"title":"How to Run Structured Output Evals at Scale","href":"/guides/use-cases/run-batch-evals"},{"title":"Building an LLM-as-a-Judge System for AI (Customer Support) Agent","href":"/guides/prompts/llm-as-a-judge"}]},{"group":"Prompt Engineering","pages":[{"title":null,"href":"/guides/prompts"},{"title":"Ultimate AI SDR","href":"/guides/prompts/ultimate-ai-sdr"},{"title":"Build a chatbot using Portkey's Prompt Templates","href":"/guides/prompts/build-a-chatbot-using-portkeys-prompt-templates"},{"title":"Building an LLM-as-a-Judge System for AI (Customer Support) Agent","href":"/guides/prompts/llm-as-a-judge"},{"title":"Optimizing Prompts for Customer Support using Portkey | LLama Prompt Ops Integration","href":"/guides/prompts/llama-prompts"}]},{"group":"Whitepapers","pages":[{"group":"Optimizing LLM Costs","pages":[{"title":"Executive Summary","href":"/guides/whitepapers/optimizing-llm-costs/executive-summary"},{"title":"1. Introduction","href":"/guides/whitepapers/optimizing-llm-costs/introduction"},{"title":"2. Understanding LLM Cost Drivers","href":"/guides/whitepapers/optimizing-llm-costs/llm-cost-drivers"},{"title":"3. FrugalGPT Techniques for Cost Optimization","href":"/guides/whitepapers/optimizing-llm-costs/frugalgpt-techniques"},{"title":"4. Advanced Strategies for Performance Improvement","href":"/guides/whitepapers/optimizing-llm-costs/advanced-strategies"},{"title":"5. Architectural Considerations","href":"/guides/whitepapers/optimizing-llm-costs/architectural-considerations"},{"title":"6. Operational Best Pracitces","href":"/guides/whitepapers/optimizing-llm-costs/operational-best-practices"},{"title":"7. Cost Effective Development Practices","href":"/guides/whitepapers/optimizing-llm-costs/cost-effective-development"},{"title":"8. User Education and Change Management","href":"/guides/whitepapers/optimizing-llm-costs/user-education"},{"title":"9. Future Trends in LLM Cost Optimization","href":"/guides/whitepapers/optimizing-llm-costs/future-trends"},{"title":"10. Conclusion and Key Takeaways","href":"/guides/whitepapers/optimizing-llm-costs/conclusion-and-key-takeaways"}]}]},{"group":"Getting Started","pages":[{"title":"Overview","href":"/guides/getting-started"},{"title":"A/B Test Prompts and Models","href":"/guides/getting-started/a-b-test-prompts-and-models"},{"title":"Tackling Rate Limiting","href":"/guides/getting-started/tackling-rate-limiting"},{"title":"Function Calling","href":"/guides/getting-started/function-calling"},{"title":"Image Generation","href":"/guides/getting-started/image-generation"},{"title":"Getting Started with AI Gateway","href":"/guides/getting-started/getting-started-with-ai-gateway"},{"title":"Llama 3 on Groq","href":"/guides/getting-started/llama-3-on-groq"},{"title":"Return Repeat Requests from Cache","href":"/guides/getting-started/return-repeat-requests-from-cache"},{"title":"Trigger Automatic Retries on LLM Failures","href":"/guides/getting-started/trigger-automatic-retries-on-llm-failures"},{"title":"101 on Portkey's Gateway Configs","href":"/guides/getting-started/101-on-portkey-s-gateway-configs"}]},{"group":"Integrations","pages":[{"title":"Overview","href":"/guides/integrations"},{"title":"Arize with Portkey: Multi-LLM Debate with Traces \u0026 Evals","href":"/guides/integrations/arize-portkey"},{"title":"Llama 3 on Portkey + Together AI","href":"/guides/integrations/llama-3-on-portkey-+-together-ai"},{"title":"Introduction to GPT-4o","href":"/guides/integrations/introduction-to-gpt-4o"},{"title":"Anyscale","href":"/guides/integrations/anyscale"},{"title":"Mistral","href":"/guides/integrations/mistral"},{"title":"Vercel AI","href":"/guides/integrations/vercel-ai"},{"title":"Deepinfra","href":"/guides/integrations/deepinfra"},{"title":"Groq","href":"/guides/integrations/groq"},{"title":"Langchain","href":"/guides/integrations/langchain"},{"title":"Mixtral 8x22b","href":"/guides/integrations/mixtral-8x22b"},{"title":"Segmind","href":"/guides/integrations/segmind"}]},{"group":"Use Cases","pages":[{"title":"Overview","href":"/guides/use-cases"},{"title":"Web Search for Any LLM in LibreChat","href":"/guides/use-cases/librechat-web-search"},{"title":"Few-Shot Prompting","description":"LLMs are highly capable of following a given structure. By providing a few examples of how the assistant should respond to a given prompt, the LLM can generate responses that closely follow the format of these examples.","href":"/guides/use-cases/few-shot-prompting"},{"title":"Enforcing JSON Schema with Anyscale \u0026 Together","href":"/guides/use-cases/enforcing-json-schema-with-anyscale-and-together"},{"title":"Detecting Emotions with GPT-4o","description":null,"href":"/guides/use-cases/emotions-with-gpt-4o"},{"title":"Build an article suggestion app with Supabase pgvector, and Portkey","href":"/guides/use-cases/build-an-article-suggestion-app-with-supabase-pgvector-and-portkey"},{"title":"Setting up resilient Load balancers with failure-mitigating Fallbacks","href":"/guides/use-cases/setting-up-resilient-load-balancers-with-failure-mitigating-fallbacks"},{"title":"Combining Routing Strategies: Conditional, Load Balancing \u0026 Fallbacks","href":"/guides/use-cases/combining-routing-strategies"},{"title":"Run Portkey on Prompts from Langchain Hub","href":"/guides/use-cases/run-portkey-on-prompts-from-langchain-hub"},{"title":"Smart Fallback with Model-Optimized Prompts","href":"/guides/use-cases/smart-fallback-with-model-optimized-prompts"},{"title":"How to use OpenAI SDK with Portkey Prompt Templates","href":"/guides/use-cases/how-to-use-openai-sdk-with-portkey-prompt-templates"},{"title":"Setup OpenAI -> Azure OpenAI Fallback","href":"/guides/use-cases/setup-openai-greater-than-azure-openai-fallback"},{"title":"Fallback from SDXL to Dall-e-3","href":"/guides/use-cases/fallback-from-sdxl-to-dall-e-3"},{"title":"Comparing Top10 LMSYS Models with Portkey","href":"/guides/use-cases/comparing-top10-lmsys-models-with-portkey"},{"title":"Request metadata use cases","href":"/guides/use-cases/metadata-use-cases"},{"title":"Tracking LLM Costs Per User with Portkey","href":"/guides/use-cases/track-costs-using-metadata"},{"title":"Enforcing Budget, Token \u0026 Rate Limits: Use Cases","href":"/guides/use-cases/enforcing-limits-and-budgets"},{"title":"Comparing DeepSeek Models Against OpenAI, Anthropic \u0026 More Using Portkey","href":"/guides/use-cases/deepseek-r1"},{"title":"Portkey with OpenAI Computer Use","href":"/guides/use-cases/openai-computer-use"},{"title":"Using Private MCP Servers with Responses API","href":"/guides/use-cases/private-mcp-servers"}]}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog/2025/may"}]},{"tab":"Help articles","pages":[{"title":"Help articles","href":"/help-center/you-do-not-have-enough-permissions"}]}]}]},"basePath":"","title":"Enforcing JSON Schema with Anyscale \u0026 Together - Portkey (Prisma AIRS AI Gateway) Docs","buildId":"dpl_BSPUBxEoKhhK7HzXVDPxdPvWx4xc","deploymentId":"dpl_BSPUBxEoKhhK7HzXVDPxdPvWx4xc","dynamics":[],"chunks":[]}