Note
If you are a new user, we recommend using Jamba Instruct, our newest foundation model. Jurassic (J2) models will no longer be supported by November 11, 2024.
To generate text completions and responses for a given prompt, you can send an HTTP request to the complete
endpoint of your desired Jurassic-2 language model. This request should include the input text prompt as well as any relevant parameters for controlling the text generation. Additionally, you must include your API key in the request headers for authentication purposes.
Once you've sent your complete
request, you'll receive a response that includes the tokenized prompt, as well as the generated text response(s). This generated text is referred to as completions, and can include multiple outputs depending on the parameters you set. The response may also contain additional metadata relevant to the generation process.
Jurassic-2 Models
Our state-of-the-art Jurassic-2 language models series, encompasses three variants - Ultra, Mid, and Light. These models are distinguished by their unwavering delivery of superior performance and broad flexibility, excelling in diverse tasks.
Light: Designed for fast responses, this model can be used to optimize performance for relatively simple tasks.
Mid: This model offers enhanced text generation capabilities, making it well-suited to language tasks with a greater degree of complexity.
Ultra: As the largest and most powerful model in the Jurassic series, J2-Ultra is an ideal choice for the most complex language processing tasks and generative text applications.
API Parameters
Each of these parameters can be used to customize the behavior of the Jurassic-2 language models, allowing developers to fine-tune the model's responses to better suit their needs:
prompt
: This is the starting point for generating responses. The format of the prompt, whether zero-shot, few-shot, or instructional, can influence the shape of the model's responses. Refer to this guide for more on prompt engineering.
numResults
: The number of responses to generate for a given prompt.
maxTokens
: The maximum number of tokens to generate for each response.
minTokens
: The minimum number of tokens to generate for each response.
temperature
: A value controlling the "creativity" of the model's responses.
topP
: A value controlling the diversity of the model's responses.
stopSequences
: A list of sequences that, when generated, will cause the model to stop generating tokens.
topKReturn
: The number of top-scoring tokens to consider for each generation step.
frequencyPenalty
: A penalty applied to tokens that are frequently generated.
presencePenalty
: A penalty applied to tokens that are already present in the prompt.
countPenalty
: A penalty applied to tokens based on their frequency in the generated responses.
Example API Requests
fetch("https://api.ai21.com/studio/v1/j2-mid/complete", {
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"prompt": "These are a few of my favorite",
"numResults": 1,
"maxTokens": 30,
"temperature": 0.7,
"topKReturn": 0,
"topP":1,
"countPenalty": {
"scale": 0,
"applyToNumbers": false,
"applyToPunctuations": false,
"applyToStopwords": false,
"applyToWhitespaces": false,
"applyToEmojis": false
},
"frequencyPenalty": {
"scale": 0,
"applyToNumbers": false,
"applyToPunctuations": false,
"applyToStopwords": false,
"applyToWhitespaces": false,
"applyToEmojis": false
},
"presencePenalty": {
"scale": 0,
"applyToNumbers": false,
"applyToPunctuations": false,
"applyToStopwords": false,
"applyToWhitespaces": false,
"applyToEmojis": false
},
"stopSequences":["##"]
}),
method: "POST"
});
fetch("https://api.ai21.com/studio/v1/j2-ultra/complete", {
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"prompt": "List down 3 actionable steps to improve customer retention in my online tour agency. Each step should not exceed a length of 13 words.",
"numResults": 1,
"maxTokens": 100,
"temperature": 0.8,
"topKReturn": 0,
"topP":1,
"countPenalty": {
"scale": 0,
"applyToNumbers": false,
"applyToPunctuations": false,
"applyToStopwords": false,
"applyToWhitespaces": false,
"applyToEmojis": false
},
"frequencyPenalty": {
"scale": 0,
"applyToNumbers": false,
"applyToPunctuations": false,
"applyToStopwords": false,
"applyToWhitespaces": false,
"applyToEmojis": false
},
"presencePenalty": {
"scale": 0,
"applyToNumbers": false,
"applyToPunctuations": false,
"applyToStopwords": false,
"applyToWhitespaces": false,
"applyToEmojis": false
},
"stopSequences":[]
}),
method: "POST"
});
Example Responses
{
"id": "75a54d20-dda1-6db7-ff99-59b1af4fdfd3",
"prompt": {
"text": "These are a few of my favorite",
"tokens": [
{
"generatedToken": {
"token": "âTheseâare",
"logprob": -8.139219284057617,
"raw_logprob": -8.139219284057617
},
"topTokens": null,
"textRange": {
"start": 0,
"end": 9
}
},
{
"generatedToken": {
"token": "âaâfew",
"logprob": -4.903847694396973,
"raw_logprob": -4.903847694396973
},
"topTokens": null,
"textRange": {
"start": 9,
"end": 15
}
},
{
"generatedToken": {
"token": "âofâmyâfavorite",
"logprob": -1.543039321899414,
"raw_logprob": -1.543039321899414
},
"topTokens": null,
"textRange": {
"start": 15,
"end": 30
}
}
]
},
"completions": [
{
"data": {
"text": " things!\n\nI love entertaining, entertaining and decorating my home, entertaining clients, entertaining friends, entertaining family...you get the point! One of my favorite things to do is plan parties",
"tokens": [
{
"generatedToken": {
"token": "âthings",
"logprob": -0.012797726318240166,
"raw_logprob": -0.24019983410835266
},
"topTokens": null,
"textRange": {
"start": 0,
"end": 7
}
},
{
"generatedToken": {
"token": "!",
"logprob": -2.060641050338745,
"raw_logprob": -2.189206600189209
},
"topTokens": null,
"textRange": {
"start": 7,
"end": 8
}
},
{
"generatedToken": {
"token": "<|newline|>",
"logprob": -0.8403825759887695,
"raw_logprob": -2.1910078525543213
},
"topTokens": null,
"textRange": {
"start": 8,
"end": 9
}
},
{
"generatedToken": {
"token": "<|newline|>",
"logprob": -0.1456860452890396,
"raw_logprob": -0.9437531232833862
},
"topTokens": null,
"textRange": {
"start": 9,
"end": 10
}
},
{
"generatedToken": {
"token": "âIâlove",
"logprob": -4.374380588531494,
"raw_logprob": -4.643549919128418
},
"topTokens": null,
"textRange": {
"start": 10,
"end": 16
}
},
{
"generatedToken": {
"token": "âentertaining",
"logprob": -8.783716201782227,
"raw_logprob": -8.083599090576172
},
"topTokens": null,
"textRange": {
"start": 16,
"end": 29
}
},
{
"generatedToken": {
"token": ",",
"logprob": -1.0627485513687134,
"raw_logprob": -1.545505404472351
},
"topTokens": null,
"textRange": {
"start": 29,
"end": 30
}
},
{
"generatedToken": {
"token": "âentertaining",
"logprob": -4.874294757843018,
"raw_logprob": -4.618663787841797
},
"topTokens": null,
"textRange": {
"start": 30,
"end": 43
}
},
{
"generatedToken": {
"token": "âand",
"logprob": -3.167405605316162,
"raw_logprob": -3.570988655090332
},
"topTokens": null,
"textRange": {
"start": 43,
"end": 47
}
},
{
"generatedToken": {
"token": "âdecorating",
"logprob": -1.648970127105713,
"raw_logprob": -2.582613706588745
},
"topTokens": null,
"textRange": {
"start": 47,
"end": 58
}
},
{
"generatedToken": {
"token": "âmyâhome",
"logprob": -2.5026865005493164,
"raw_logprob": -2.6586031913757324
},
"topTokens": null,
"textRange": {
"start": 58,
"end": 66
}
},
{
"generatedToken": {
"token": ",",
"logprob": -0.7689361572265625,
"raw_logprob": -1.2174654006958008
},
"topTokens": null,
"textRange": {
"start": 66,
"end": 67
}
},
{
"generatedToken": {
"token": "âentertaining",
"logprob": -1.2487196922302246,
"raw_logprob": -2.0927321910858154
},
"topTokens": null,
"textRange": {
"start": 67,
"end": 80
}
},
{
"generatedToken": {
"token": "âclients",
"logprob": -8.5693359375,
"raw_logprob": -7.141331672668457
},
"topTokens": null,
"textRange": {
"start": 80,
"end": 88
}
},
{
"generatedToken": {
"token": ",",
"logprob": -0.1822780817747116,
"raw_logprob": -0.6432795524597168
},
"topTokens": null,
"textRange": {
"start": 88,
"end": 89
}
},
{
"generatedToken": {
"token": "âentertaining",
"logprob": -0.5468096137046814,
"raw_logprob": -1.3048734664916992
},
"topTokens": null,
"textRange": {
"start": 89,
"end": 102
}
},
{
"generatedToken": {
"token": "âfriends",
"logprob": -0.9710591435432434,
"raw_logprob": -1.7686699628829956
},
"topTokens": null,
"textRange": {
"start": 102,
"end": 110
}
},
{
"generatedToken": {
"token": ",",
"logprob": -0.14025729894638062,
"raw_logprob": -0.4739122986793518
},
"topTokens": null,
"textRange": {
"start": 110,
"end": 111
}
},
{
"generatedToken": {
"token": "âentertaining",
"logprob": -0.2804214358329773,
"raw_logprob": -0.8527922034263611
},
"topTokens": null,
"textRange": {
"start": 111,
"end": 124
}
},
{
"generatedToken": {
"token": "âfamily",
"logprob": -1.0800895690917969,
"raw_logprob": -1.927623987197876
},
"topTokens": null,
"textRange": {
"start": 124,
"end": 131
}
},
{
"generatedToken": {
"token": "...",
"logprob": -2.514098644256592,
"raw_logprob": -2.373312473297119
},
"topTokens": null,
"textRange": {
"start": 131,
"end": 134
}
},
{
"generatedToken": {
"token": "you",
"logprob": -1.0778509378433228,
"raw_logprob": -1.99626624584198
},
"topTokens": null,
"textRange": {
"start": 134,
"end": 137
}
},
{
"generatedToken": {
"token": "âget",
"logprob": -0.03242425248026848,
"raw_logprob": -0.1461254507303238
},
"topTokens": null,
"textRange": {
"start": 137,
"end": 141
}
},
{
"generatedToken": {
"token": "âtheâpoint",
"logprob": -2.4119038581848145,
"raw_logprob": -2.0218327045440674
},
"topTokens": null,
"textRange": {
"start": 141,
"end": 151
}
},
{
"generatedToken": {
"token": "!",
"logprob": -1.4457058906555176,
"raw_logprob": -1.3022156953811646
},
"topTokens": null,
"textRange": {
"start": 151,
"end": 152
}
},
{
"generatedToken": {
"token": "âOneâofâmyâfavorite",
"logprob": -5.320619583129883,
"raw_logprob": -5.056370258331299
},
"topTokens": null,
"textRange": {
"start": 152,
"end": 171
}
},
{
"generatedToken": {
"token": "âthingsâtoâdo",
"logprob": -0.678179919719696,
"raw_logprob": -1.1683768033981323
},
"topTokens": null,
"textRange": {
"start": 171,
"end": 184
}
},
{
"generatedToken": {
"token": "âis",
"logprob": -0.08321860432624817,
"raw_logprob": -0.5311100482940674
},
"topTokens": null,
"textRange": {
"start": 184,
"end": 187
}
},
{
"generatedToken": {
"token": "âplan",
"logprob": -2.2561252117156982,
"raw_logprob": -3.04398512840271
},
"topTokens": null,
"textRange": {
"start": 187,
"end": 192
}
},
{
"generatedToken": {
"token": "âparties",
"logprob": -2.2673985958099365,
"raw_logprob": -2.537139892578125
},
"topTokens": null,
"textRange": {
"start": 192,
"end": 200
}
}
]
},
"finishReason": {
"reason": "length",
"length": 30
}
}
]
}
{
"id": "8e674143-7e8a-0a66-6195-6db5f8db81c1",
"prompt": {
"text": "List down 3 actionable steps to improve customer retention in my online tour agency. Each step should not exceed a length of 8 words.",
"tokens": [
{
"generatedToken": {
"token": "âList",
"logprob": -9.527595520019531,
"raw_logprob": -9.527595520019531
},
"topTokens": null,
"textRange": {
"start": 0,
"end": 4
}
},
{
"generatedToken": {
"token": "âdown",
"logprob": -6.910721302032471,
"raw_logprob": -6.910721302032471
},
"topTokens": null,
"textRange": {
"start": 4,
"end": 9
}
},
{
"generatedToken": {
"token": "â",
"logprob": -2.366292715072632,
"raw_logprob": -2.366292715072632
},
"topTokens": null,
"textRange": {
"start": 9,
"end": 10
}
},
{
"generatedToken": {
"token": "3",
"logprob": -1.9308538436889648,
"raw_logprob": -1.9308538436889648
},
"topTokens": null,
"textRange": {
"start": 10,
"end": 11
}
},
{
"generatedToken": {
"token": "âactionable",
"logprob": -11.569904327392578,
"raw_logprob": -11.569904327392578
},
"topTokens": null,
"textRange": {
"start": 11,
"end": 22
}
},
{
"generatedToken": {
"token": "âsteps",
"logprob": -1.1354386806488037,
"raw_logprob": -1.1354386806488037
},
"topTokens": null,
"textRange": {
"start": 22,
"end": 28
}
},
{
"generatedToken": {
"token": "âtoâimprove",
"logprob": -3.1558408737182617,
"raw_logprob": -3.1558408737182617
},
"topTokens": null,
"textRange": {
"start": 28,
"end": 39
}
},
{
"generatedToken": {
"token": "âcustomerâretention",
"logprob": -4.270885467529297,
"raw_logprob": -4.270885467529297
},
"topTokens": null,
"textRange": {
"start": 39,
"end": 58
}
},
{
"generatedToken": {
"token": "âinâmy",
"logprob": -12.904643058776855,
"raw_logprob": -12.904643058776855
},
"topTokens": null,
"textRange": {
"start": 58,
"end": 64
}
},
{
"generatedToken": {
"token": "âonline",
"logprob": -7.207955837249756,
"raw_logprob": -7.207955837249756
},
"topTokens": null,
"textRange": {
"start": 64,
"end": 71
}
},
{
"generatedToken": {
"token": "âtour",
"logprob": -10.250415802001953,
"raw_logprob": -10.250415802001953
},
"topTokens": null,
"textRange": {
"start": 71,
"end": 76
}
},
{
"generatedToken": {
"token": "âagency",
"logprob": -2.711249589920044,
"raw_logprob": -2.711249589920044
},
"topTokens": null,
"textRange": {
"start": 76,
"end": 83
}
},
{
"generatedToken": {
"token": ".",
"logprob": -7.662383079528809,
"raw_logprob": -7.662383079528809
},
"topTokens": null,
"textRange": {
"start": 83,
"end": 84
}
},
{
"generatedToken": {
"token": "âEach",
"logprob": -15.142401695251465,
"raw_logprob": -15.142401695251465
},
"topTokens": null,
"textRange": {
"start": 84,
"end": 89
}
},
{
"generatedToken": {
"token": "âstep",
"logprob": -0.5286767482757568,
"raw_logprob": -0.5286767482757568
},
"topTokens": null,
"textRange": {
"start": 89,
"end": 94
}
},
{
"generatedToken": {
"token": "âshouldânotâexceed",
"logprob": -7.191850662231445,
"raw_logprob": -7.191850662231445
},
"topTokens": null,
"textRange": {
"start": 94,
"end": 112
}
},
{
"generatedToken": {
"token": "âaâlengthâof",
"logprob": -13.557117462158203,
"raw_logprob": -13.557117462158203
},
"topTokens": null,
"textRange": {
"start": 112,
"end": 124
}
},
{
"generatedToken": {
"token": "â",
"logprob": -0.039575375616550446,
"raw_logprob": -0.039575375616550446
},
"topTokens": null,
"textRange": {
"start": 124,
"end": 125
}
},
{
"generatedToken": {
"token": "13",
"logprob": -5.851505279541016,
"raw_logprob": -5.851505279541016
},
"topTokens": null,
"textRange": {
"start": 125,
"end": 126
}
},
{
"generatedToken": {
"token": "âwords",
"logprob": -0.4432293772697449,
"raw_logprob": -0.4432293772697449
},
"topTokens": null,
"textRange": {
"start": 126,
"end": 132
}
},
{
"generatedToken": {
"token": ".",
"logprob": -4.019333362579346,
"raw_logprob": -4.019333362579346
},
"topTokens": null,
"textRange": {
"start": 132,
"end": 133
}
}
]
},
"completions": [
{
"data": {
"text": "\n1. Collect feedback: Regularly ask for feedback from customers to identify areas for improvement.\n2. Communicate: Respond to customer inquiries promptly and communicate effectively.\n3. Offer value: Provide value to customers through loyalty programs, discounts, and other incentives.",
"tokens": [
{
"generatedToken": {
"token": "<|newline|>",
"logprob": -0.00027211778797209263,
"raw_logprob": -0.0018670998979359865
},
"topTokens": null,
"textRange": {
"start": 0,
"end": 1
}
},
{
"generatedToken": {
"token": "â",
"logprob": -0.016294162720441818,
"raw_logprob": -0.05574732646346092
},
"topTokens": null,
"textRange": {
"start": 1,
"end": 1
}
},
{
"generatedToken": {
"token": "1",
"logprob": -0.0001436368766007945,
"raw_logprob": -0.0011181537993252277
},
"topTokens": null,
"textRange": {
"start": 1,
"end": 2
}
},
{
"generatedToken": {
"token": ".",
"logprob": -0.007074899971485138,
"raw_logprob": -0.018024694174528122
},
"topTokens": null,
"textRange": {
"start": 2,
"end": 3
}
},
{
"generatedToken": {
"token": "âCollect",
"logprob": -3.177037000656128,
"raw_logprob": -3.1195967197418213
},
"topTokens": null,
"textRange": {
"start": 3,
"end": 11
}
},
{
"generatedToken": {
"token": "âfeedback",
"logprob": -1.0296190977096558,
"raw_logprob": -1.0809664726257324
},
"topTokens": null,
"textRange": {
"start": 11,
"end": 20
}
},
{
"generatedToken": {
"token": ":",
"logprob": -2.2967185974121094,
"raw_logprob": -2.2603893280029297
},
"topTokens": null,
"textRange": {
"start": 20,
"end": 21
}
},
{
"generatedToken": {
"token": "âRegularly",
"logprob": -2.1934618949890137,
"raw_logprob": -2.470489740371704
},
"topTokens": null,
"textRange": {
"start": 21,
"end": 31
}
},
{
"generatedToken": {
"token": "âaskâfor",
"logprob": -1.9096498489379883,
"raw_logprob": -1.9893324375152588
},
"topTokens": null,
"textRange": {
"start": 31,
"end": 39
}
},
{
"generatedToken": {
"token": "âfeedbackâfrom",
"logprob": -1.7532850503921509,
"raw_logprob": -1.7661702632904053
},
"topTokens": null,
"textRange": {
"start": 39,
"end": 53
}
},
{
"generatedToken": {
"token": "âcustomers",
"logprob": -0.04718722775578499,
"raw_logprob": -0.11064490675926208
},
"topTokens": null,
"textRange": {
"start": 53,
"end": 63
}
},
{
"generatedToken": {
"token": "âtoâidentify",
"logprob": -2.8281068801879883,
"raw_logprob": -2.646435260772705
},
"topTokens": null,
"textRange": {
"start": 63,
"end": 75
}
},
{
"generatedToken": {
"token": "âareasâfor",
"logprob": -0.20255455374717712,
"raw_logprob": -0.43675974011421204
},
"topTokens": null,
"textRange": {
"start": 75,
"end": 85
}
},
{
"generatedToken": {
"token": "âimprovement",
"logprob": -0.00030751267331652343,
"raw_logprob": -0.0019519339548423886
},
"topTokens": null,
"textRange": {
"start": 85,
"end": 97
}
},
{
"generatedToken": {
"token": ".",
"logprob": -0.002855392638593912,
"raw_logprob": -0.013682624325156212
},
"topTokens": null,
"textRange": {
"start": 97,
"end": 98
}
},
{
"generatedToken": {
"token": "<|newline|>",
"logprob": -0.2002774477005005,
"raw_logprob": -0.27886962890625
},
"topTokens": null,
"textRange": {
"start": 98,
"end": 99
}
},
{
"generatedToken": {
"token": "â",
"logprob": -0.00014101465058047324,
"raw_logprob": -0.0008320921915583313
},
"topTokens": null,
"textRange": {
"start": 99,
"end": 99
}
},
{
"generatedToken": {
"token": "2",
"logprob": -0.000009298280929215252,
"raw_logprob": -0.00012611546844709665
},
"topTokens": null,
"textRange": {
"start": 99,
"end": 100
}
},
{
"generatedToken": {
"token": ".",
"logprob": -0.000016212332411669195,
"raw_logprob": -0.00029523781267926097
},
"topTokens": null,
"textRange": {
"start": 100,
"end": 101
}
},
{
"generatedToken": {
"token": "âCommunicate",
"logprob": -2.300893783569336,
"raw_logprob": -2.4192047119140625
},
"topTokens": null,
"textRange": {
"start": 101,
"end": 113
}
},
{
"generatedToken": {
"token": ":",
"logprob": -0.44318583607673645,
"raw_logprob": -0.6422646045684814
},
"topTokens": null,
"textRange": {
"start": 113,
"end": 114
}
},
{
"generatedToken": {
"token": "âRespondâto",
"logprob": -5.636350154876709,
"raw_logprob": -4.778336048126221
},
"topTokens": null,
"textRange": {
"start": 114,
"end": 125
}
},
{
"generatedToken": {
"token": "âcustomer",
"logprob": -0.2475288063287735,
"raw_logprob": -0.4310404658317566
},
"topTokens": null,
"textRange": {
"start": 125,
"end": 134
}
},
{
"generatedToken": {
"token": "âinquiries",
"logprob": -0.2658867835998535,
"raw_logprob": -0.3859763741493225
},
"topTokens": null,
"textRange": {
"start": 134,
"end": 144
}
},
{
"generatedToken": {
"token": "âpromptly",
"logprob": -0.5114702582359314,
"raw_logprob": -0.6828909516334534
},
"topTokens": null,
"textRange": {
"start": 144,
"end": 153
}
},
{
"generatedToken": {
"token": "âand",
"logprob": -0.736537754535675,
"raw_logprob": -1.0030481815338135
},
"topTokens": null,
"textRange": {
"start": 153,
"end": 157
}
},
{
"generatedToken": {
"token": "âcommunicateâeffectively",
"logprob": -2.4961466789245605,
"raw_logprob": -2.6236460208892822
},
"topTokens": null,
"textRange": {
"start": 157,
"end": 181
}
},
{
"generatedToken": {
"token": ".",
"logprob": -0.5211674571037292,
"raw_logprob": -0.8128488659858704
},
"topTokens": null,
"textRange": {
"start": 181,
"end": 182
}
},
{
"generatedToken": {
"token": "<|newline|>",
"logprob": -0.00020430385484360158,
"raw_logprob": -0.0019150504376739264
},
"topTokens": null,
"textRange": {
"start": 182,
"end": 183
}
},
{
"generatedToken": {
"token": "â",
"logprob": -0.00000822540732769994,
"raw_logprob": -0.00011538793478393927
},
"topTokens": null,
"textRange": {
"start": 183,
"end": 183
}
},
{
"generatedToken": {
"token": "3",
"logprob": -0.000046967357775429264,
"raw_logprob": -0.00040820849244482815
},
"topTokens": null,
"textRange": {
"start": 183,
"end": 184
}
},
{
"generatedToken": {
"token": ".",
"logprob": -0.000002264974000354414,
"raw_logprob": -0.00005793403761344962
},
"topTokens": null,
"textRange": {
"start": 184,
"end": 185
}
},
{
"generatedToken": {
"token": "âOffer",
"logprob": -1.059805989265442,
"raw_logprob": -1.3295007944107056
},
"topTokens": null,
"textRange": {
"start": 185,
"end": 191
}
},
{
"generatedToken": {
"token": "âvalue",
"logprob": -1.2525863647460938,
"raw_logprob": -1.3292828798294067
},
"topTokens": null,
"textRange": {
"start": 191,
"end": 197
}
},
{
"generatedToken": {
"token": ":",
"logprob": -0.0013294914970174432,
"raw_logprob": -0.005798661150038242
},
"topTokens": null,
"textRange": {
"start": 197,
"end": 198
}
},
{
"generatedToken": {
"token": "âProvide",
"logprob": -0.3367600739002228,
"raw_logprob": -0.47396910190582275
},
"topTokens": null,
"textRange": {
"start": 198,
"end": 206
}
},
{
"generatedToken": {
"token": "âvalue",
"logprob": -2.3782360553741455,
"raw_logprob": -2.463621139526367
},
"topTokens": null,
"textRange": {
"start": 206,
"end": 212
}
},
{
"generatedToken": {
"token": "âtoâcustomers",
"logprob": -0.497890442609787,
"raw_logprob": -0.6806918978691101
},
"topTokens": null,
"textRange": {
"start": 212,
"end": 225
}
},
{
"generatedToken": {
"token": "âthrough",
"logprob": -0.1690589189529419,
"raw_logprob": -0.3055683374404907
},
"topTokens": null,
"textRange": {
"start": 225,
"end": 233
}
},
{
"generatedToken": {
"token": "âloyaltyâprogram",
"logprob": -1.922332525253296,
"raw_logprob": -1.9207100868225098
},
"topTokens": null,
"textRange": {
"start": 233,
"end": 249
}
},
{
"generatedToken": {
"token": "s",
"logprob": -0.0960625633597374,
"raw_logprob": -0.18698658049106598
},
"topTokens": null,
"textRange": {
"start": 249,
"end": 250
}
},
{
"generatedToken": {
"token": ",",
"logprob": -0.0017080017132684588,
"raw_logprob": -0.008203974924981594
},
"topTokens": null,
"textRange": {
"start": 250,
"end": 251
}
},
{
"generatedToken": {
"token": "âdiscounts",
"logprob": -0.030362939462065697,
"raw_logprob": -0.09098570793867111
},
"topTokens": null,
"textRange": {
"start": 251,
"end": 261
}
},
{
"generatedToken": {
"token": ",",
"logprob": -0.0019408691441640258,
"raw_logprob": -0.008601993322372437
},
"topTokens": null,
"textRange": {
"start": 261,
"end": 262
}
},
{
"generatedToken": {
"token": "âandâother",
"logprob": -0.7544885873794556,
"raw_logprob": -0.9290801286697388
},
"topTokens": null,
"textRange": {
"start": 262,
"end": 272
}
},
{
"generatedToken": {
"token": "âincentives",
"logprob": -0.3496859073638916,
"raw_logprob": -0.46906837821006775
},
"topTokens": null,
"textRange": {
"start": 272,
"end": 283
}
},
{
"generatedToken": {
"token": ".",
"logprob": -0.09370804578065872,
"raw_logprob": -0.17617759108543396
},
"topTokens": null,
"textRange": {
"start": 283,
"end": 284
}
},
{
"generatedToken": {
"token": "<|endoftext|>",
"logprob": -0.005900938529521227,
"raw_logprob": -0.017361216247081757
},
"topTokens": null,
"textRange": {
"start": 284,
"end": 284
}
}
]
},
"finishReason": {
"reason": "endoftext"
}
}
]
}
Response
The response is a nested data structure containing information about the processed request, prompt, and completions. At the top level, the response has the following fields:
ID
A unique string id
for the processed request. Repeated identical requests receive different IDs.
prompt
The prompt
includes the raw text, the tokens with their log probabilities, and the top-K alternative tokens at each position, if requested. It has two nested fields:
text
(string)tokens
(list of TokenData)
completions
A list of completions, including raw text, tokens, and log probabilities. The number of completions corresponds to the requested numResults
. Each completion has two nested fields:
-
data
, which contains thetext
(string) and tokens (list of TokenData) for the completion. -
finishReason
, This nested data structure explains why the generation process was halted for a specific completion. The various termination reasons are:- Length Limit Reached:
- Format:
{"reason": "length", "length": <max_length>}
- Description: The model halted generation upon reaching the preset token limit. Here,
<max_length>
represents the setmaxTokens
value, indicating the maximum token count.
- Format:
- End-of-text Token Generated:
- Format:
{"reason": "endoftext"}
- Description: Generation was terminated when the model produced the
<endoftext>
token.
- Format:
- Stop Sequence Generated:
- Format:
{"reason": "stop", "sequence": <stop_sequence>}
- Description: Generation concluded once the specified stop sequence was generated. The
<stop_sequence>
refers to the value provided instopSequences
.
- Format:
- Length Limit Reached:
TokenData
The TokenData object provides detailed information about each token in both the prompt and the completions. It includes the following fields:
generatedToken:
The generatedToken
field consists of two nested fields:
token
: The string representation of the token.logprob
: The predicted log probability of the token after applying the sampling parameters as a float value.raw_logprob
: The raw predicted log probability of the token as a float value. For the indifferent values (namely,temperature=1
,topP=1
) we getraw_logprob=logprob
.
topTokens
The topTokens
field is a list of the top K alternative tokens for this position, sorted by probability, according to the topKReturn
request parameter. If topKReturn
is set to 0, this field will be null.
Each token in the list includes:
token
: The string representation of the alternative token.logprob
: The predicted log probability of the alternative token as a float value.
textRange
The textRange
field indicates the start and end offsets of the token in the decoded text string:
start
: The starting index of the token in the decoded text string.end
: The ending index of the token in the decoded text string.