import asynciofrom ai21 import AsyncAI21Clientfrom ai21.models.chat import ChatMessagemessages = [ChatMessage(content="What is the meaning of life?", role="user")]client = AsyncAI21Client()async def main(): response = await client.chat.completions.create( messages=messages, model="jamba-large", stream=True, ) async for chunk in response: print(chunk.choices[0].delta.content, end="")asyncio.run(main())
from ai21 import AI21Clientfrom ai21.models.chat import ChatMessagemessages = [ChatMessage(content="What is the meaning of life?", role="user")]client = AI21Client()response = client.chat.completions.create( messages=messages, model="jamba-large", stream=True,)for chunk in response: print(chunk.choices[0].delta.content, end="")
Foundation Models
Chat response
import asynciofrom ai21 import AsyncAI21Clientfrom ai21.models.chat import ChatMessagemessages = [ChatMessage(content="What is the meaning of life?", role="user")]client = AsyncAI21Client()async def main(): response = await client.chat.completions.create( messages=messages, model="jamba-large", stream=True, ) async for chunk in response: print(chunk.choices[0].delta.content, end="")asyncio.run(main())
from ai21 import AI21Clientfrom ai21.models.chat import ChatMessagemessages = [ChatMessage(content="What is the meaning of life?", role="user")]client = AI21Client()response = client.chat.completions.create( messages=messages, model="jamba-large", stream=True,)for chunk in response: print(chunk.choices[0].delta.content, end="")
Response details
Non-streaming results
A successful non-streamed response includes the following members:
string
Unique ID for each request (not message). Same ID for all responses in a streaming response.
object[]
One or more responses, depending on the n parameter from the request.
Each response includes the following members.
Show properties
object
Zero-based index of the message in the list of messages. Note that this might not correspond with the position in the response list.
object
The message generated by the model. Includes two fields: role and content.
object[]
Tool calls only occur if a tools parameter was specified in the request. These tool calls apply solely to the current message, and returned values should be added to the message thread in both the assistant message tool_calls fields and the tool message.
Show properties
string
ID of the tool call, generated by the model.
string
The type of tool called. Currently the only possible value is “function”.
object
The invoked function.
Show properties
string
The name of the function, which you specified in your request.
object
A JSON object containing the function’s parameters and values.
string
Why the message ended.
Show properties
string
The response ended naturally as a complete answer (due to end-of-sequence token) or because the model generated a stop sequence provided in the request.
string
The response ended by reaching max_tokens.
object
The token counts for this request.
Per-token billing is based on the prompt token and completion token counts and rates.
Show properties
integer
Number of tokens in the prompt for this request.
The prompt token contains the entire message history and extra tokens for combining messages, proportional to the number of messages.
integer
Number of tokens in the response message.
integer
prompt_tokens and completion_tokens.
Streamed results
Setting stream = true in the request will return a stream of messages, each containing one token. You can read more about streaming calls using the SDK.The final message will be data: [DONE]. All other messages will have data set to a JSON object with the following fields:
object
An object containing either an object with the following members, or the string “DONE” for the last message.
string
Unique ID for each request (not message). Same ID for all streaming responses.
object
An array with one object containing the following fields:
integer
Always zero.
object
The first message in the stream will be an object set to {"role":"assistant"}.
Subsequent messages will have an object {"content": **token**} with the generated token.
string
Why the message ended.
Show properties
object
The last message includes this field, which shows the total token counts for the request. Per-token billing is based on the prompt token and completion token counts and rates.
When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request.
Show properties
integer
Number of tokens in the prompt for this request.
The prompt token contains the entire message history and extra tokens for combining messages, proportional to the number of messages.
integer
Number of tokens in the response message.
integer
prompt_tokens and completion_tokens.
usage will be null except for the last chunk which contains the token usage statistics for the entire request.
import asynciofrom ai21 import AsyncAI21Clientfrom ai21.models.chat import ChatMessagemessages = [ChatMessage(content="What is the meaning of life?", role="user")]client = AsyncAI21Client()async def main(): response = await client.chat.completions.create( messages=messages, model="jamba-large", stream=True, ) async for chunk in response: print(chunk.choices[0].delta.content, end="")asyncio.run(main())
from ai21 import AI21Clientfrom ai21.models.chat import ChatMessagemessages = [ChatMessage(content="What is the meaning of life?", role="user")]client = AI21Client()response = client.chat.completions.create( messages=messages, model="jamba-large", stream=True,)for chunk in response: print(chunk.choices[0].delta.content, end="")
Error Codes
500 - Internal Server Error
429 - Too Many Requests (You are sending requests too quickly.)
503 - Service Unavailable (The engine is currently overloaded, please try again later)
401 - Unauthorized (Incorrect API key provided/Invalid Authentication)
403 - Access Denied
422 - Unprocurable Entity (Request body is malformed)
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"AI21 Labs","colors":{"primary":"#F098B5","light":"#EE87A7","dark":"#F098B5"},"logo":{"light":"https://mintcdn.com/ai21-demo/ae4eOvPS_ZOlDCYT/images/AI21_Logo_black.png?fit=max\u0026auto=format\u0026n=ae4eOvPS_ZOlDCYT\u0026q=85\u0026s=ff9840432b0d2e9ebcbadc46ee2b5b8f","dark":"https://mintcdn.com/ai21-demo/ae4eOvPS_ZOlDCYT/images/AI21_Logo_white.png?fit=max\u0026auto=format\u0026n=ae4eOvPS_ZOlDCYT\u0026q=85\u0026s=8a9b3dd3ba0831a3431f51d792cef4c3","href":"https://www.ai21.com/"},"favicon":"https://mintcdn.com/ai21-demo/oHuzynnpYbW6Dt6q/favicon.png?fit=max\u0026auto=format\u0026n=oHuzynnpYbW6Dt6q\u0026q=85\u0026s=2b79127bf528ced3b4c82a2245c3977b","appearance":{"default":"light"},"background":{"decoration":"gradient","color":{"dark":"#212121"}},"navbar":{"links":[{"href":"https://studio.ai21.com/v2/workspaces/81189ce4-f4d4-433e-954d-ff17cd040a2a/maestro","label":"Playground"},{"href":"https://studio.ai21.com/v2/account/api-key?source=docs\u0026_gl=1*u1mkxz*_gcl_au*OTIzMDQ5NzU0LjE3NDkyOTE4NjA.","label":"API Key"}],"primary":{"type":"button","label":"Get a Demo","href":"https://www.ai21.com/talk-to-us/"}},"footer":{"socials":{"linkedin":"https://www.linkedin.com/company/ai21","x":"https://twitter.com/AI21Labs","discord":"https://discord.com/invite/cKzg6GEAyB"}},"seo":{"metatags":{"title":"AI21 Labs Documentation","description":"Access full API references, guides, and model capabilities. Learn how to work with AI21's foundation models."}},"fonts":{"heading":{"family":"Polysans","source":"https://www.ai21.com/wp-content/themes/ai21/assets/fonts/polysans/polysans-500.woff2","format":"woff2"},"body":{"family":"Inter"}},"styling":{"codeblocks":"system","latex":false},"integrations":{"amplitude":{"apiKey":"be0223327acdb089744156d19857f1ac"},"intercom":{"appId":"mj4rlz0i"}},"contextual":{"options":["copy","view"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"ai21-demo","hasAudioNarration":false,"actualSubdomain":"ai21-demo","customDomains":["docs.ai21.com"],"gitSource":{"type":"github","owner":"ai21labs","repo":"ai21-documentation","deployBranch":"mintlify-migration","contentDirectory":"","isPrivate":true,"mountPath":"","label":"","_id":"6b10b34c9ffae5051c3ffa2d"},"feedback":{"thumbs":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae927afce2e4391f29e39da:success","clientVersion":"0.0.4428","searchFilterCounts":[{"language":"default","tag":"Guides","count":39},{"language":"default","tag":"API Reference","count":15},{"language":"default","tag":"AI21 Maestro","count":14},{"language":"default","tag":"Tools","count":11},{"language":"default","tag":"Foundation Models","count":7},{"language":"default","tag":"File Library Management","count":7},{"language":"default","tag":"AI21 Studio","count":6},{"language":"default","tag":"Private AI","count":4},{"language":"default","tag":"User Provided Tools","count":4},{"language":"default","tag":"Getting Started","count":3}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"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":"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":"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":"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":"turbopuffer-dual-write","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":"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":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[{"filePath":"styles/custom.css","content":".tryit-button{display:none!important}button[aria-label=\"Try it\"]{display:none!important}.centered-table{text-align:center}.centered-table table{margin:0 auto!important;display:table!important}div.centered-table>table{margin-left:auto!important;margin-right:auto!important}.dark .hero{color:#ffffff!important}.dark .hero h1{font-weight:500!important}h1{font-weight:500!important}h2{font-weight:400!important;font-size:1.4rem!important;line-height:1.4!important;letter-spacing:-0.01em!important;margin-bottom:0.6em!important}.category-title{font-size:1.75rem!important;font-weight:500!important;line-height:1.3!important;margin-top:2rem!important;margin-bottom:1rem!important;letter-spacing:normal!important}.home-page a.box h2,.home-page .box h2{font-size:1rem!important;font-weight:400!important;line-height:1.2!important;margin-bottom:0.4em!important;letter-spacing:-0.01em!important}.sidebar a,.sidebar .category,.sidebar .group-title{font-weight:400!important}.sidebar .title{font-weight:300!important}.card h2{font-size:1.125rem!important;font-weight:500!important;line-height:1.5!important;margin-bottom:0.4em!important;letter-spacing:-0.01em!important}.bg-lightmode{background-image:url('https://mintlify-assets.b-cdn.net/ai21-background.svg')}.bg-darkmode{background-image:url('https://mintlify-assets.b-cdn.net/dark-ai21-background2.svg')}"}]}
{"page":{"pagePath":"reference/jamba-api-response","slug":"/reference/jamba-api-response","pageMetadata":{"title":"Chat response","description":null,"href":"/reference/jamba-api-response","hidden":false},"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`,br:`br`,code:`code`,hr:`hr`,li:`li`,p:`p`,ul:`ul`,..._provideComponents(),...props.components},{Expandable,Heading,ParamField}=_components;if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`response-details`,children:`Response details`}),`\n`,_jsx(Heading,{level:`3`,id:`non-streaming-results`,children:`Non-streaming results`}),`\n`,_jsx(_components.p,{children:`A successful non-streamed response includes the following members:`}),`\n`,_jsx(ParamField,{body:`id`,type:`string`,id:`param-id`,children:_jsx(_components.p,{children:`Unique ID for each request (not message). Same ID for all responses in a streaming response.`})}),`\n`,_jsx(ParamField,{body:`choices`,type:`object[]`,id:`param-choices`,children:_jsxs(_components.p,{children:[`One or more responses, depending on the `,_jsx(_components.code,{children:`n`}),` parameter from the request.\nEach response includes the following members.`]})}),`\n`,_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`index`,type:`object`,id:`param-index`,children:_jsx(_components.p,{children:`Zero-based index of the message in the list of messages. Note that this might not correspond with the position in the response list.`})}),_jsx(ParamField,{body:`message`,type:`object`,id:`param-message`,children:_jsxs(_components.p,{children:[`The message generated by the model. Includes two fields: `,_jsx(_components.code,{children:`role`}),` and `,_jsx(_components.code,{children:`content`}),`.`]})}),_jsxs(ParamField,{body:`tool_calls`,type:`object[]`,id:`param-tool-calls`,children:[_jsx(_components.p,{children:`Tool calls only occur if a tools parameter was specified in the request. These tool calls apply solely to the current message, and returned values should be added to the message thread in both the assistant message tool_calls fields and the tool message.`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`id`,type:`string`,id:`param-id-1`,children:_jsx(_components.p,{children:`ID of the tool call, generated by the model.`})}),_jsx(ParamField,{body:`type`,type:`string`,id:`param-type`,children:_jsx(_components.p,{children:`The type of tool called. Currently the only possible value is “function”.`})}),_jsxs(ParamField,{body:`function`,type:`object`,id:`param-function`,children:[_jsx(_components.p,{children:`The invoked function.`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`name`,type:`string`,id:`param-name`,children:_jsx(_components.p,{children:`The name of the function, which you specified in your request.`})}),_jsx(ParamField,{body:`arguments`,type:`object`,id:`param-arguments`,children:_jsx(_components.p,{children:`A JSON object containing the function’s parameters and values.`})})]})]})]})]})]}),`\n`,_jsxs(ParamField,{body:`finish_reason`,type:`string`,id:`param-finish-reason`,children:[_jsx(_components.p,{children:`Why the message ended.`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`stop`,type:`string`,id:`param-stop`,children:_jsx(_components.p,{children:`The response ended naturally as a complete answer (due to end-of-sequence token) or because the model generated a stop sequence provided in the request.`})}),_jsx(ParamField,{body:`length`,type:`string`,id:`param-length`,children:_jsx(_components.p,{children:`The response ended by reaching max_tokens.`})})]})]}),`\n`,_jsxs(ParamField,{body:`usage`,type:`object`,id:`param-usage`,children:[_jsx(_components.p,{children:`The token counts for this request.\nPer-token billing is based on the prompt token and completion token counts and rates.`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`prompt_tokens`,type:`integer`,id:`param-prompt-tokens`,children:_jsx(_components.p,{children:`Number of tokens in the prompt for this request.\nThe prompt token contains the entire message history and extra tokens for combining messages, proportional to the number of messages.`})}),_jsx(ParamField,{body:`completion_tokens`,type:`integer`,id:`param-completion-tokens`,children:_jsx(_components.p,{children:`Number of tokens in the response message.`})}),_jsx(ParamField,{body:`total_tokens`,type:`integer`,id:`param-total-tokens`,children:_jsx(_components.p,{children:`prompt_tokens and completion_tokens.`})})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`streamed-results`,children:`Streamed results`}),`\n`,_jsxs(_components.p,{children:[`Setting `,_jsx(_components.code,{children:`stream = true`}),` in the request will return a stream of messages, each containing one token. You can read more about streaming calls using the `,_jsx(_components.a,{href:`https://github.com/AI21Labs/ai21-python/blob/main/README.md#Streaming`,children:`SDK`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`The final message will be `,_jsx(_components.code,{children:`data: [DONE]`}),`. All other messages will have `,_jsx(_components.code,{children:`data`}),` set to a JSON object with the following fields:`]}),`\n`,_jsx(ParamField,{body:`data`,type:`object`,id:`param-data`,children:_jsx(_components.p,{children:`An object containing either an object with the following members, or the string “DONE” for the last message.`})}),`\n`,_jsx(ParamField,{body:`id`,type:`string`,id:`param-id-2`,children:_jsx(_components.p,{children:`Unique ID for each request (not message). Same ID for all streaming responses.`})}),`\n`,_jsx(ParamField,{body:`choices`,type:`object`,id:`param-choices-1`,children:_jsx(_components.p,{children:`An array with one object containing the following fields:`})}),`\n`,_jsx(ParamField,{body:`index`,type:`integer`,id:`param-index-1`,children:_jsx(_components.p,{children:`Always zero.`})}),`\n`,_jsx(ParamField,{body:`delta`,type:`object`,id:`param-delta`,children:_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`The first message in the stream will be an object set to `,_jsx(_components.code,{children:`{\"role\":\"assistant\"}`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Subsequent messages will have an object `,_jsx(_components.code,{children:`{\"content\": **token**}`}),` with the generated token.`]}),`\n`]})}),`\n`,_jsxs(ParamField,{body:`finish_reason`,type:`string`,id:`param-finish-reason-1`,children:[_jsx(_components.p,{children:`Why the message ended.`}),_jsx(Expandable,{title:`properties`,children:_jsxs(ParamField,{body:`usage`,type:`object`,id:`param-usage-1`,children:[_jsx(_components.p,{children:`The last message includes this field, which shows the total token counts for the request. Per-token billing is based on the prompt token and completion token counts and rates.\nWhen present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request.`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`prompt_tokens`,type:`integer`,id:`param-prompt-tokens-1`,children:_jsx(_components.p,{children:`Number of tokens in the prompt for this request.\nThe prompt token contains the entire message history and extra tokens for combining messages, proportional to the number of messages.`})}),_jsx(ParamField,{body:`completion_tokens`,type:`integer`,id:`param-completion-tokens-1`,children:_jsx(_components.p,{children:`Number of tokens in the response message.`})}),_jsx(ParamField,{body:`total_tokens`,type:`integer`,id:`param-total-tokens-1`,children:_jsx(_components.p,{children:`prompt_tokens and completion_tokens.`})})]})]})})]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`usage`}),` will be `,_jsx(_components.code,{children:`null`}),` except for the last chunk which contains the token usage statistics for the entire request.`]}),`\n`,`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`error-codes`,children:`Error Codes`}),`\n`,_jsxs(_components.p,{children:[`500 - Internal Server Error`,_jsx(_components.br,{}),`\n`,`429 - Too Many Requests (You are sending requests too quickly.)`,_jsx(_components.br,{}),`\n`,`503 - Service Unavailable (The engine is currently overloaded, please try again later)`,_jsx(_components.br,{}),`\n`,`401 - Unauthorized (Incorrect API key provided/Invalid Authentication)`,_jsx(_components.br,{}),`\n`,`403 - Access Denied`,_jsx(_components.br,{}),`\n`,`422 - Unprocurable Entity (Request body is malformed)`]}),`\n`,_jsx(_components.hr,{})]})}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":"Chat response","description":null,"href":"/reference/jamba-api-response","hidden":false}}},"mdxSourceWithNoJs":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,br:`br`,code:`code`,hr:`hr`,li:`li`,p:`p`,pre:`pre`,span:`span`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Expandable,Heading,ParamField,ResponseExample}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!ResponseExample)_missingMdxReference(`ResponseExample`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`response-details`,children:`Response details`}),`\n`,_jsx(Heading,{level:`3`,id:`non-streaming-results`,children:`Non-streaming results`}),`\n`,_jsx(_components.p,{children:`A successful non-streamed response includes the following members:`}),`\n`,_jsx(ParamField,{body:`id`,type:`string`,id:`param-id`,children:_jsx(_components.p,{children:`Unique ID for each request (not message). Same ID for all responses in a streaming response.`})}),`\n`,_jsx(ParamField,{body:`choices`,type:`object[]`,id:`param-choices`,children:_jsxs(_components.p,{children:[`One or more responses, depending on the `,_jsx(_components.code,{children:`n`}),` parameter from the request.\nEach response includes the following members.`]})}),`\n`,_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`index`,type:`object`,id:`param-index`,children:_jsx(_components.p,{children:`Zero-based index of the message in the list of messages. Note that this might not correspond with the position in the response list.`})}),_jsx(ParamField,{body:`message`,type:`object`,id:`param-message`,children:_jsxs(_components.p,{children:[`The message generated by the model. Includes two fields: `,_jsx(_components.code,{children:`role`}),` and `,_jsx(_components.code,{children:`content`}),`.`]})}),_jsxs(ParamField,{body:`tool_calls`,type:`object[]`,id:`param-tool-calls`,children:[_jsx(_components.p,{children:`Tool calls only occur if a tools parameter was specified in the request. These tool calls apply solely to the current message, and returned values should be added to the message thread in both the assistant message tool_calls fields and the tool message.`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`id`,type:`string`,id:`param-id-1`,children:_jsx(_components.p,{children:`ID of the tool call, generated by the model.`})}),_jsx(ParamField,{body:`type`,type:`string`,id:`param-type`,children:_jsx(_components.p,{children:`The type of tool called. Currently the only possible value is “function”.`})}),_jsxs(ParamField,{body:`function`,type:`object`,id:`param-function`,children:[_jsx(_components.p,{children:`The invoked function.`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`name`,type:`string`,id:`param-name`,children:_jsx(_components.p,{children:`The name of the function, which you specified in your request.`})}),_jsx(ParamField,{body:`arguments`,type:`object`,id:`param-arguments`,children:_jsx(_components.p,{children:`A JSON object containing the function’s parameters and values.`})})]})]})]})]})]}),`\n`,_jsxs(ParamField,{body:`finish_reason`,type:`string`,id:`param-finish-reason`,children:[_jsx(_components.p,{children:`Why the message ended.`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`stop`,type:`string`,id:`param-stop`,children:_jsx(_components.p,{children:`The response ended naturally as a complete answer (due to end-of-sequence token) or because the model generated a stop sequence provided in the request.`})}),_jsx(ParamField,{body:`length`,type:`string`,id:`param-length`,children:_jsx(_components.p,{children:`The response ended by reaching max_tokens.`})})]})]}),`\n`,_jsxs(ParamField,{body:`usage`,type:`object`,id:`param-usage`,children:[_jsx(_components.p,{children:`The token counts for this request.\nPer-token billing is based on the prompt token and completion token counts and rates.`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`prompt_tokens`,type:`integer`,id:`param-prompt-tokens`,children:_jsx(_components.p,{children:`Number of tokens in the prompt for this request.\nThe prompt token contains the entire message history and extra tokens for combining messages, proportional to the number of messages.`})}),_jsx(ParamField,{body:`completion_tokens`,type:`integer`,id:`param-completion-tokens`,children:_jsx(_components.p,{children:`Number of tokens in the response message.`})}),_jsx(ParamField,{body:`total_tokens`,type:`integer`,id:`param-total-tokens`,children:_jsx(_components.p,{children:`prompt_tokens and completion_tokens.`})})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`streamed-results`,children:`Streamed results`}),`\n`,_jsxs(_components.p,{children:[`Setting `,_jsx(_components.code,{children:`stream = true`}),` in the request will return a stream of messages, each containing one token. You can read more about streaming calls using the `,_jsx(_components.a,{href:`https://github.com/AI21Labs/ai21-python/blob/main/README.md#Streaming`,children:`SDK`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`The final message will be `,_jsx(_components.code,{children:`data: [DONE]`}),`. All other messages will have `,_jsx(_components.code,{children:`data`}),` set to a JSON object with the following fields:`]}),`\n`,_jsx(ParamField,{body:`data`,type:`object`,id:`param-data`,children:_jsx(_components.p,{children:`An object containing either an object with the following members, or the string “DONE” for the last message.`})}),`\n`,_jsx(ParamField,{body:`id`,type:`string`,id:`param-id-2`,children:_jsx(_components.p,{children:`Unique ID for each request (not message). Same ID for all streaming responses.`})}),`\n`,_jsx(ParamField,{body:`choices`,type:`object`,id:`param-choices-1`,children:_jsx(_components.p,{children:`An array with one object containing the following fields:`})}),`\n`,_jsx(ParamField,{body:`index`,type:`integer`,id:`param-index-1`,children:_jsx(_components.p,{children:`Always zero.`})}),`\n`,_jsx(ParamField,{body:`delta`,type:`object`,id:`param-delta`,children:_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`The first message in the stream will be an object set to `,_jsx(_components.code,{children:`{\"role\":\"assistant\"}`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Subsequent messages will have an object `,_jsx(_components.code,{children:`{\"content\": **token**}`}),` with the generated token.`]}),`\n`]})}),`\n`,_jsxs(ParamField,{body:`finish_reason`,type:`string`,id:`param-finish-reason-1`,children:[_jsx(_components.p,{children:`Why the message ended.`}),_jsx(Expandable,{title:`properties`,children:_jsxs(ParamField,{body:`usage`,type:`object`,id:`param-usage-1`,children:[_jsx(_components.p,{children:`The last message includes this field, which shows the total token counts for the request. Per-token billing is based on the prompt token and completion token counts and rates.\nWhen present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request.`}),_jsxs(Expandable,{title:`properties`,children:[_jsx(ParamField,{body:`prompt_tokens`,type:`integer`,id:`param-prompt-tokens-1`,children:_jsx(_components.p,{children:`Number of tokens in the prompt for this request.\nThe prompt token contains the entire message history and extra tokens for combining messages, proportional to the number of messages.`})}),_jsx(ParamField,{body:`completion_tokens`,type:`integer`,id:`param-completion-tokens-1`,children:_jsx(_components.p,{children:`Number of tokens in the response message.`})}),_jsx(ParamField,{body:`total_tokens`,type:`integer`,id:`param-total-tokens-1`,children:_jsx(_components.p,{children:`prompt_tokens and completion_tokens.`})})]})]})})]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`usage`}),` will be `,_jsx(_components.code,{children:`null`}),` except for the last chunk which contains the token usage statistics for the entire request.`]}),`\n`,_jsxs(ResponseExample,{children:[_jsx(CodeBlock,{filename:`Python (Non-streaming results)`,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:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` asyncio`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\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:` ai21 `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` AsyncAI21Client`})]}),`\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:` ai21.models.chat `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ChatMessage`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`messages `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [ChatMessage(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`content`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"What is the meaning of life?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`role`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--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:`)]`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` AsyncAI21Client()`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\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:` def`}),_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:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` 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\":`#D4D4D4`},children:` client.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:`messages,`})]}),`\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:`\"jamba-large\"`}),_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:` stream`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_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:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` chunk `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response:`})]}),`\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:`(chunk.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].delta.content, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`end`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`asyncio.run(main())`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`Python (Streamed results)`,numberOfLines:`14`,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:`14`,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:` ai21 `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` AI21Client`})]}),`\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:` ai21.models.chat `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ChatMessage`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`messages `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [ChatMessage(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`content`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"What is the meaning of life?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`role`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--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:`)]`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` AI21Client()`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.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:`messages,`})]}),`\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:`\"jamba-large\"`}),_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:` stream`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_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:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` chunk `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response:`})]}),`\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:`(chunk.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].delta.content, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`end`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})})]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`error-codes`,children:`Error Codes`}),`\n`,_jsxs(_components.p,{children:[`500 - Internal Server Error`,_jsx(_components.br,{}),`\n`,`429 - Too Many Requests (You are sending requests too quickly.)`,_jsx(_components.br,{}),`\n`,`503 - Service Unavailable (The engine is currently overloaded, please try again later)`,_jsx(_components.br,{}),`\n`,`401 - Unauthorized (Incorrect API key provided/Invalid Authentication)`,_jsx(_components.br,{}),`\n`,`403 - Access Denied`,_jsx(_components.br,{}),`\n`,`422 - Unprocurable Entity (Request body is malformed)`]}),`\n`,_jsx(_components.hr,{})]})}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":"Chat response","description":null,"href":"/reference/jamba-api-response","hidden":false}}}},"mdxExtracts":{"tableOfContents":[{"title":"Response details","slug":"response-details","depth":2,"children":[{"title":"Non-streaming results","slug":"non-streaming-results","depth":3,"children":[]},{"title":"Streamed results","slug":"streamed-results","depth":3,"children":[]}]},{"title":"Error Codes","slug":"error-codes","depth":2,"children":[]}],"codeExamples":{"response":{"type":"ResponseExample","children":[{"filename":"Python (Non-streaming results)","html":"\u003cpre class=\"shiki shiki-themes github-light-default dark-plus\" style=\"background-color:#ffffff;--shiki-dark-bg:#0B0C0E;color:#1f2328;--shiki-dark:#D4D4D4\" language=\"python\">\u003ccode language=\"python\" numberOfLines=\"21\">\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> asyncio\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">from\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> ai21 \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> AsyncAI21Client\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">from\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> ai21.models.chat \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> ChatMessage\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">messages \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> [ChatMessage(\u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\">content\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"What is the meaning of life?\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\">role\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"user\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)]\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">client \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> AsyncAI21Client()\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">async\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> main\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">():\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> response \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> await\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> client.chat.completions.create(\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\"> messages\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">messages,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\"> model\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"jamba-large\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\"> stream\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\">True\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> )\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> async\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> for\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> chunk \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">in\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> response:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#DCDCAA\"> print\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(chunk.choices[\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#B5CEA8\">0\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">].delta.content, \u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\">end\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">asyncio.run(main())\u003c/span>\u003c/span>\n\u003c/code>\u003c/pre>"},{"filename":"Python (Streamed results)","html":"\u003cpre class=\"shiki shiki-themes github-light-default dark-plus\" style=\"background-color:#ffffff;--shiki-dark-bg:#0B0C0E;color:#1f2328;--shiki-dark:#D4D4D4\" language=\"python\">\u003ccode language=\"python\" numberOfLines=\"14\">\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">from\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> ai21 \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> AI21Client\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">from\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> ai21.models.chat \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> ChatMessage\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">messages \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> [ChatMessage(\u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\">content\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"What is the meaning of life?\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\">role\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"user\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)]\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">client \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> AI21Client()\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">response \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> client.chat.completions.create(\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\"> messages\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">messages,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\"> model\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"jamba-large\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\"> stream\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\">True\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">for\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> chunk \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">in\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> response:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#DCDCAA\"> print\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(chunk.choices[\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#B5CEA8\">0\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">].delta.content, \u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\">end\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)\u003c/span>\u003c/span>\n\u003c/code>\u003c/pre>"}],"attributes":[]}}},"jsLinks":[],"subdomain":"ai21-demo","siteName":"AI21 Labs","title":"Chat response - AI21 Labs","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-02-19T12:51:32.978Z","originalFileLocation":"reference/jamba-api-response.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=\"light\"}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=\"Access full API references, guides, and model capabilities. Learn how to work with AI21\u0026#x27;s foundation models.\">\u003cmeta data-mint-head name=\"application-name\" content=\"AI21 Labs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/ai21-demo/zc4uXZjknsciGHPW/_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=\"/mintlify-assets/_mintlify/favicons/ai21-demo/zc4uXZjknsciGHPW/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/ai21-demo/zc4uXZjknsciGHPW/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/ai21-demo/zc4uXZjknsciGHPW/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/ai21-demo/zc4uXZjknsciGHPW/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/ai21-demo/zc4uXZjknsciGHPW/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/ai21-demo/zc4uXZjknsciGHPW/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/ai21-demo/zc4uXZjknsciGHPW/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/ai21-demo/zc4uXZjknsciGHPW/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Chat response - AI21 Labs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Access full API references, guides, and model capabilities. Learn how to work with AI21\u0026#x27;s foundation models.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"AI21 Labs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.ai21.com/reference/jamba-api-response\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://ai21-demo.mintlify.site/_mintlify/api/og/v2?division=Foundation+Models\u0026amp;title=Chat+response\u0026amp;theme=db641889c50a4115ea9b934e\u0026amp;signature=c6a7c49a20fcd42445c07a2f92bdbc4713cf67f4c4dd6031d77bcf7c3720f58e\">\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=\"Chat response - AI21 Labs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Access full API references, guides, and model capabilities. Learn how to work with AI21\u0026#x27;s foundation models.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://ai21-demo.mintlify.site/_mintlify/api/og/v2?division=Foundation+Models\u0026amp;title=Chat+response\u0026amp;theme=db641889c50a4115ea9b934e\u0026amp;signature=c6a7c49a20fcd42445c07a2f92bdbc4713cf67f4c4dd6031d77bcf7c3720f58e\">\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=\"/mintlify-assets/_mintlify/favicons/ai21-demo/zc4uXZjknsciGHPW/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"AI21 Labs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#F098B5\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.ai21.com/reference/jamba-api-response\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/reference/jamba-api-response.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.ai21.com/#organization\",\"name\":\"AI21 Labs\",\"url\":\"https://docs.ai21.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/ai21-demo/ae4eOvPS_ZOlDCYT/images/AI21_Logo_black.png?fit=max\u0026auto=format\u0026n=ae4eOvPS_ZOlDCYT\u0026q=85\u0026s=ff9840432b0d2e9ebcbadc46ee2b5b8f\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.ai21.com#website\",\"name\":\"AI21 Labs\",\"url\":\"https://docs.ai21.com\",\"publisher\":{\"@id\":\"https://docs.ai21.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.ai21.com/reference/jamba-api-response#webpage\",\"url\":\"https://docs.ai21.com/reference/jamba-api-response\",\"name\":\"Chat response\",\"dateModified\":\"2026-02-19T12:51:32.978Z\",\"isPartOf\":{\"@id\":\"https://docs.ai21.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.ai21.com/reference/jamba-api-response#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.ai21.com/reference/jamba-api-response#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Foundation Models\",\"item\":\"https://docs.ai21.com/reference/jamba-1-6-api-ref\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Chat response\",\"item\":\"https://docs.ai21.com/reference/jamba-api-response\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.ai21.com/reference/jamba-api-response#article\",\"headline\":\"Chat response\",\"name\":\"Chat response\",\"url\":\"https://docs.ai21.com/reference/jamba-api-response\",\"mainEntityOfPage\":{\"@id\":\"https://docs.ai21.com/reference/jamba-api-response#webpage\"},\"dateModified\":\"2026-02-19T12:51:32.978Z\",\"publisher\":{\"@id\":\"https://docs.ai21.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.ai21.com#website\"}}]}\u003c/script>","agentPointerHref":"/reference/jamba-api-response.md","siteName":"AI21 Labs","nav":{"global":null,"tabs":[{"tab":"Home","pages":[{"title":"Home","href":"/home"}]},{"tab":"Guides","pages":[{"title":"Guides","href":"/docs/overview"}]},{"tab":"API Reference","groups":[{"group":"Using the APIs","pages":[{"title":"Introduction","href":"/reference/introduction"},{"title":"Authentication","href":"/reference/authentication"},{"title":"Rate Limits","href":"/reference/api-rate-limits"}]},{"group":"AI21 Maestro","pages":[{"title":"Create run","api":"POST https://api.ai21.com/studio/v1/maestro/runs","href":"/reference/maestro-create-run"},{"title":"Retrieve run status","api":"GET https://api.ai21.com/studio/v1/maestro/runs/{run_id}","href":"/reference/retrieve-run"},{"title":"Run object","mode":"wide","href":"/reference/run-object"}]},{"group":"Foundation Models","pages":[{"title":" Chat request","sidebarTitle":"Chat request","api":"POST https://api.ai21.com/studio/v1/chat/completions","description":null,"href":"/reference/jamba-1-6-api-ref"},{"title":"Chat response","href":"/reference/jamba-api-response"}]},{"group":"File Library Management","pages":[{"title":"File Library","sidebarTitle":"Overview","description":null,"href":"/reference/manage-library-ref"},{"title":"Upload workspace files","api":"POST https://api.ai21.com/studio/v1/library/files","href":"/reference/manage-library-ref/upload-workspace-files"},{"title":"List library files","api":"GET https://api.ai21.com/studio/v1/library/files","href":"/reference/manage-library-ref/list-library-files"},{"title":"Get workspace file","api":"GET https://api.ai21.com/studio/v1/library/files/{file_id}","href":"/reference/manage-library-ref/get-workspace-files"},{"title":"Get file download link","api":"GET https://api.ai21.com/studio/v1/library/files/{file_id}/download","href":"/reference/manage-library-ref/get-file-download-link"},{"title":"Update file","api":"PUT https://api.ai21.com/studio/v1/library/files/{file_id}","href":"/reference/manage-library-ref/update-file"},{"title":"Delete file","api":"DELETE https://api.ai21.com/studio/v1/library/files/{file_id}","href":"/reference/manage-library-ref/delete-file"}]}]},{"tab":"Updates","pages":[{"title":"Updates","href":"/changelog"}]}]},"basePath":"","title":"Chat response - AI21 Labs","deploymentId":"dpl_4dgnk6TA5fUgboKHTvWWyeqm3idh","buildId":"dpl_4dgnk6TA5fUgboKHTvWWyeqm3idh","dynamics":["2b790eda92"],"chunks":["ApiExamples-BnqLE2Kf.js","usePlaygroundInputsStore-DhQKVH9n.js","shallow-BOCfJNQU.js","utils-D3TDKJCH.js","utils-u8TSWPiZ.js","isEqual-BrbSa25D.js","_Uint8Array-BuOv0f5_.js","isObject-FP1Yky1u.js","CodeSnippets-DUGBlB-S.js","CodeSnippet-CuGpPhIN.js","snippetPresets-D3m2eL-0.js","style-to-object-BY3JEAdk.js","use-playground-group-access-DYZiRN3l.js","cloneDeep-Cyl7LOol.js","v4-DIgz8zy6.js"]}