Responses
Asynchronous task result query interface, used to query results of asynchronous inference tasks, also supports direct synchronous call for content generation.
Endpoint
POST https://ai-tokenhub.com/api/v1/responsesAuthorizations
BearerAuth
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token authentication. Use your API key or platform authentication token, virtual keys (prefixed with sk-bf-) can also be passed here. Format: Bearer YOUR_API_KEY |
| Content-Type | string | Yes | application/json |
Request Body
application/json
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| model | string | Yes | - | Model identifier, format: provider/model (e.g.: doubao-seed-2-0-pro)Example: "doubao-seed-2-0-pro" |
| input | string/object[] | Yes | - | Input content, can be text string or message array |
| stream | boolean | No | false | Whether to enable streaming response |
| temperature | number | No | 0.7 | Generation temperature, value range: -2 <= x <= 2 |
| frequency_penalty | number | No | 0 | Frequency penalty, value range: -2 <= x <= 2 |
| presence_penalty | number | No | 0 | Presence penalty, value range: -2 <= x <= 2 |
| max_tokens | integer | No | - | Maximum number of generated tokens |
| metadata | object | No | - | User-defined metadata |
| parallel_tool_calls | boolean | No | true | Whether to enable parallel tool calls |
| tool_choice | string/object | No | "auto" | Tool call selection strategy |
| tools | object[] | No | - | List of available tools |
| top_p | number | No | 0.9 | Nucleus sampling parameter |
| user | string | No | - | User identifier |
Request Examples
bash
curl https://ai-tokenhub.com/api/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "doubao-seed-2-0-pro",
"input": "Tell me a joke about computers",
"temperature": 0.7
}'python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://ai-tokenhub.com/api/v1"
)
response = client.responses.create(
model="doubao-seed-2-0-pro",
input="Tell me a joke about computers",
temperature=0.7
)
print(response.output[0].content[0].text)javascript
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'YOUR_API_KEY',
baseURL: 'https://ai-tokenhub.com/api/v1'
});
const response = await client.responses.create({
model: 'doubao-seed-2-0-pro',
input: 'Tell me a joke about computers',
temperature: 0.7
});
console.log(response.output[0].content[0].text);java
import okhttp3.*;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
String json = "{\"model\":\"doubao-seed-2-0-pro\"," +
"\"input\":\"Tell me a joke about computers\"," +
"\"temperature\":0.7}";
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(json, mediaType);
Request request = new Request.Builder()
.url("https://ai-tokenhub.com/api/v1/responses")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer YOUR_API_KEY")
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}Response Example
json
{
"completed_at": 1700000300,
"created_at": 1700000000,
"error": null,
"frequency_penalty": 0.5,
"id": "resp_abc123",
"incomplete_details": null,
"instructions": [
{
"content": "Tell me a joke about computers",
"role": "user"
}
],
"metadata": {},
"model": "doubao-seed-2-0-pro",
"object": "response",
"parallel_tool_calls": true,
"presence_penalty": 0.3,
"status": "completed",
"temperature": 0.7,
"tool_choice": "auto",
"tools": [],
"top_p": 0.9,
"output": [
{
"type": "message",
"content": [
{
"text": "Why do programmers prefer dark mode? Because light attracts bugs!",
"type": "output_text"
}
],
"id": "msg-xyz789",
"role": "assistant"
}
],
"usage": {
"input_tokens": 15,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 20,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 35
}
}