Creates a text-to-text response
client.responses.create(ResponseCreateParamsbody, RequestOptionsoptions?): CreateResponseResponse { id, created, model, 23 more } | Stream<CreateResponseStreamResponse { id, choices, created, 3 more } >
/responses
Generate text responses from text prompts. This endpoint supports both streaming and non-streaming responses for VLLM models only.
Parameters
Returns
Creates a text-to-text response
import Gradient from '@digitalocean/gradient';
const client = new Gradient({
modelAccessKey: 'My Model Access Key',
});
const createResponseResponse = await client.responses.create({
input: 'Tell me a three-sentence bedtime story about a unicorn.',
model: 'llama3-8b-instruct',
});
console.log(createResponseResponse.id);
{
"id": "response-abc123def456",
"created": 1721596428,
"model": "llama3-8b-instruct",
"object": "response",
"usage": {
"input_tokens": 133,
"input_tokens_details": {
"cached_tokens": 128
},
"output_tokens": 41,
"output_tokens_details": {
"reasoning_tokens": 24,
"tool_output_tokens": 0
},
"total_tokens": 174
},
"background": true,
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Once upon a time, a unicorn named Sparkle...",
"role": "assistant",
"tool_calls": [
{
"id": "id",
"function": {
"arguments": "arguments",
"name": "name"
},
"type": "function"
}
]
},
"logprobs": {
"content": [
{
"token": "token",
"bytes": [
0
],
"logprob": 0,
"top_logprobs": [
{
"token": "token",
"bytes": [
0
],
"logprob": 0
}
]
}
]
}
}
],
"input_messages": [
{}
],
"max_output_tokens": 0,
"max_tool_calls": 0,
"output": [
{
"arguments": "arguments",
"call_id": "call_id",
"name": "name",
"type": "function_call",
"id": "id",
"encrypted_content": "encrypted_content",
"status": "status"
}
],
"output_messages": [
{}
],
"parallel_tool_calls": true,
"previous_response_id": "previous_response_id",
"prompt": "prompt",
"reasoning": "reasoning",
"service_tier": "service_tier",
"status": "status",
"temperature": 0,
"text": "text",
"tool_choice": "tool_choice",
"tools": [
{
"type": "function",
"description": "description",
"name": "name",
"parameters": {
"foo": "bar"
}
}
],
"top_logprobs": 0,
"top_p": 0,
"truncation": "truncation",
"user": "user"
}Returns Examples
{
"id": "response-abc123def456",
"created": 1721596428,
"model": "llama3-8b-instruct",
"object": "response",
"usage": {
"input_tokens": 133,
"input_tokens_details": {
"cached_tokens": 128
},
"output_tokens": 41,
"output_tokens_details": {
"reasoning_tokens": 24,
"tool_output_tokens": 0
},
"total_tokens": 174
},
"background": true,
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Once upon a time, a unicorn named Sparkle...",
"role": "assistant",
"tool_calls": [
{
"id": "id",
"function": {
"arguments": "arguments",
"name": "name"
},
"type": "function"
}
]
},
"logprobs": {
"content": [
{
"token": "token",
"bytes": [
0
],
"logprob": 0,
"top_logprobs": [
{
"token": "token",
"bytes": [
0
],
"logprob": 0
}
]
}
]
}
}
],
"input_messages": [
{}
],
"max_output_tokens": 0,
"max_tool_calls": 0,
"output": [
{
"arguments": "arguments",
"call_id": "call_id",
"name": "name",
"type": "function_call",
"id": "id",
"encrypted_content": "encrypted_content",
"status": "status"
}
],
"output_messages": [
{}
],
"parallel_tool_calls": true,
"previous_response_id": "previous_response_id",
"prompt": "prompt",
"reasoning": "reasoning",
"service_tier": "service_tier",
"status": "status",
"temperature": 0,
"text": "text",
"tool_choice": "tool_choice",
"tools": [
{
"type": "function",
"description": "description",
"name": "name",
"parameters": {
"foo": "bar"
}
}
],
"top_logprobs": 0,
"top_p": 0,
"truncation": "truncation",
"user": "user"
}