Parameter | Type | Required | Default Value | Description |
model | string | Yes | - | Model identifier. The platform's default service ID is the same as the model name (for example, hy3, deepseek-v4-flash); the custom service format is ep-xxxxxxxx. |
messages | array | Yes | - | |
stream | boolean | No | false | Whether to enable streaming output (SSE). |
stream_options | object | No | - | Streaming options, which take effect only when stream=true. |
stream_options.include_usage | boolean | No | false | Whether the last chunk in streaming mode contains usage statistics. The platform always requests usage, and this field only controls whether to deliver it to the client. |
messages is an array of objects, where each object represents a message. The message sequence rule is: [system (optional) → user → assistant → user → ...].Field | Type | Required | Description |
role | string | Yes | Fixed as "system" |
content | string | Yes | System instructions for setting model behavior and context. |
Field | Type | Required | Description |
role | string | Yes | Fixed as "user" |
content | string or array | Yes | Plain text corresponds to a string; multimodal content corresponds to an array (see Content Part below). |
content when it is an array):Field | Type | Description |
type | string | Content type: "text" / "image_url" / "video_url" / "file_url" |
text | string | Text content when type="text". |
image_url | object | Image information when type="image_url". |
image_url.url | string | Image HTTP(S) URL or Data URL in the format of data:image/...;base64,... |
image_url.detail | string | Image resolution policy: "auto" / "low" / "high", with "auto" as the default. |
video_url | object | Video information when type="video_url". |
video_url.url | string | Video HTTP(S) URL. |
file_url | object | File information when type="file_url". |
file_url.url | string | File HTTP URL (only supports direct HTTP links and does not support Base64). |
file_url with image_url / video_url within a single message. For specifics, see the capability description of the corresponding model.Field | Type | Required | Description |
role | string | Yes | Fixed as "assistant" |
content | string | No | Model response text (required when there are no tool_calls). |
reasoning_content | string | No | Reasoning chain content. Returned in the model's response for thinking, and must be filled back in as-is during multi-turn conversations to maintain context continuity. |
reasoning_details | array | No | An array of reasoning chain blocks, containing signatures, which must be passed back as-is during multi-turn conversations to maintain context continuity. |
tool_calls | array | No | |
prefix | boolean | No | Supported by some DeepSeek models: when set to true, the model uses the content of this message as a prefix for continuation writing, which requires the corresponding Beta endpoint. Under the standard endpoint, this field is ignored and does not affect the request result. |
Field | Type | Required | Description |
role | string | Yes | Fixed as "tool" |
content | string | Yes | The result content returned by the tool function (JSON string format is recommended). |
tool_call_id | string | Yes | The value corresponding to assistant.tool_calls[].id. |
name | string | No | Tool function name. |
Parameter | Type | Required | Default Value | Value Range | Description |
temperature | float | No | 1.0 | [0.0, 2.0] | Sampling temperature. Higher values make the output more random, while lower values make it more deterministic. Generally, adjust only one of this parameter or top_p. |
top_p | float | No | 1.0 | (0.0, 1.0] | Nucleus sampling probability threshold. top_p=0 is normalized by the platform to null (equivalent to the default value). |
max_tokens | integer | No | model maximum value | ≥ 1 | The maximum number of tokens that can be generated in a single response. When this limit is exceeded, finish_reason is "length". |
max_completion_tokens | integer | No | model maximum value | ≥ 1 | The maximum number of tokens that can be generated (OpenAI's new field, semantically equivalent to max_tokens). Provide either one. The platform prioritizes using max_completion_tokens. |
n | integer | No | 1 | ≥ 1 | Number of candidate responses. When n > 1, billing is based on the total number of tokens. Some models do not support this. When the reasoning mode is enabled, n must be 1; otherwise, a 400 error is returned. |
stop | string or array | No | - | Up to 4 | Stop sequences. Stops generation immediately when a matching sequence is encountered. If more than 4 are provided, they are rejected during validation. |
seed | integer | No | - | Any integer | Random seed. When the same seed is used, the system makes its best effort to ensure consistent output. |
frequency_penalty | float | No | 0 | [-2.0, 2.0] | Frequency penalty. Positive values reduce the repetition probability of tokens that have already appeared. 0 is normalized to null. |
presence_penalty | float | No | 0 | [-2.0, 2.0] | Presence penalty. Positive values encourage the generation of new topics. 0 is normalized to null. |
logprobs | boolean | No | false | - | Whether to return the log probabilities of the output tokens. |
top_logprobs | integer | No | 0 | [0, 20] | Returns the N tokens with the highest probability at each position. This requires logprobs=true; otherwise, validation fails. |
reasoning_effort | string | No | - | "low" / "medium" / "high" | Reasoning depth. It is applicable to reasoning models. The Hunyuan model has an internal mapping conversion. |
top_k, repetition_penalty, modalities, and audio are silently ignored when passed in client requests. These parameters can only be injected via platform configuration.Parameter | Type | Required | Default Value | Description |
response_format | object | No | {"type":"text"} | Controls the response format. |
response_format.type | string | Yes | "text" | Format type: "text" / "json_object" / "json_schema". |
response_format.json_schema | object | Condition | - | Required when type="json_schema". Defines the output JSON structure. |
response_format.json_schema.name | string | Yes | - | Schema name. |
response_format.json_schema.schema | object | Yes | - | JSON Schema definition (conforms to the JSON Schema specification). |
response_format.json_schema.strict | boolean | No | false | Whether to enforce strict Schema matching. |
json_object, you must explicitly instruct the model to output JSON format within messages. Otherwise, the behavior of some models may be unpredictable.Parameter | Type | Required | Default Value | Description |
tools | array | No | - | List of tool definitions. |
tools[].type | string | Yes | - | Fixed as "function". |
tools[].function | object | Yes | - | Function definition. |
tools[].function.name | string | Yes | - | Tool function name (containing only letters, numbers, underscores, and hyphens). |
tools[].function.description | string | No | - | Describes the tool function, helping the model determine when to call it. |
tools[].function.parameters | object | No | {} | Input parameter definitions (in JSON Schema object format). |
tool_choice | string or object | No | "auto" | Tool invocation policy. See the enumeration below for details. |
parallel_tool_calls | boolean | No | true | Whether to allow parallel calls to multiple tools. |
tool_choice Valid values:Value | Description |
"none" | Does not invoke any tools (in the Hunyuan environment, the tools field is also cleared). |
"auto" | The model decides on its own whether to invoke tools (default). |
"required" | Forces the model to invoke at least one tool. Note: When the thinking mode is enabled (enabled by default for models such as deepseek-v4-*), using this value or specifying a function object will return a 400 error. You must explicitly pass thinking: {"type": "disabled"} before using it. |
{"type":"function","function":{"name":"xxx"}} | Specifies a tool to call. |
tool_choice and n. Before making a call, confirm the default policy of the model you are using:hy3: Reasoning is disabled by default, and the default reasoning intensity is low.deepseek-v4-pro and deepseek-v4-flash: Reasoning is enabled by default, and the default reasoning intensity is high.thinking: {"type": "disabled"}.Parameter | Type | Required | Default Value | Description | Applicable Model |
thinking | object | No | - | Thought mode control (standard method) | Thinking models (such as hy3, deepseek-v4-flash, glm-5.2, kimi-k3, and so on) |
thinking.type | string | Yes | - | "enabled" for enabling / "disabled" for disabling / "adaptive" for adaptive mode. This field is required when the thinking object is passed. If only budget_tokens is provided without type, a 400 error is returned. | Thinking models (same as thinking; specific available values vary by model). |
thinking.budget_tokens | integer | No | 8192 (auto-filled) | The maximum number of tokens for the reasoning process. When type=enabled and this value is not specified, it is automatically filled with 8192. This value is an expected upper limit, not a hard cutoff. The actual reasoning tokens for some models may exceed the set value. Refer to usage.completion_tokens_details.reasoning_tokens in the response for the accurate number of reasoning tokens. | Thinking models (for some models, it is for reference only and not strictly enforced). |
enable_thinking | boolean | No | - | Whether to enable the thinking mode (a simplified switch). It serves as an alternative to thinking.type and is available for some models (such as the DeepSeek series). It is recommended to uniformly use thinking.type. | DeepSeek and some other models |
thinking_budget | integer | No | - | The maximum number of tokens for the reasoning process (a simplified field). It must be used in conjunction with enable_thinking. It is recommended to uniformly use thinking.budget_tokens. | DeepSeek and some other models |
interleaved_thinking | boolean | No | - | Interleaved reasoning chain mode: It reasons and outputs concurrently, making it suitable for streaming display. This field is an extended capability. Its actual support level varies across models. Models that do not support it will ignore this field without throwing an error. | Some models (subject to the specific model capability description) |
reasoning_split | boolean | No | - | Outputs the reasoning content and the final reply in separate segments. This field is an extended capability. Models that do not support it will ignore this field without throwing an error. | Some models |
completion_tokens. It is recommended to appropriately increase max_tokens.thinking.type are not supported by all models. For example, minimax-m3 only accepts "adaptive" and "disabled". Passing "enabled" will return a 400 error. Additionally, some models may still return reasoning chain content even when "disabled" is passed. Before integration, it is recommended to conduct practical tests to confirm the behavior with the model you are using.Parameter | Type | Required | Default Value | Description | Applicable Model |
prompt_cache_key | string | No | - | Manually specify the Prompt cache key. Requests with the same key can reuse the cache. After a cache hit, billing is based on the cache price. You can view the number of cached tokens hit in the response usage.prompt_tokens_details.cached_tokens. | Models that support Prompt Cache |
Parameter | Type | Required | Default Value | Description |
user | string | No | - | Identifier of the end user, which is passed through to the model service for abuse detection and usage tracking. |
user_id | string or number | No | - | User ID at the platform business layer (compatible with numeric types, the platform automatically converts it to a string). It is used only for internal user identification within the platform and is not passed through to the model service. To pass a user identifier to the model service, use the user field. |
safety_identifier | string | No | - | Security identifier, used by the risk control system for user-level content moderation tracking. |
extra_body | object | No | - | Additional parameters passed through to the model service, which are not parsed by the platform. Some models merge this field into the top level of the request body, while other model services ignore it. |
{"id": "chatcmpl-xxxxxxxxxxxxxxxxxxxxxxxx","object": "chat.completion","created": 1750924800,"model": "<your-model-name>","choices": [...],"usage": {...},"search_info": null}
Field | Type | Description |
id | string | The unique identifier for the request, in the format chatcmpl-{uuid} (generated by the platform and independent of the ID returned by the model service). |
object | string | The object type, fixed to "chat.completion". |
created | integer | The creation time (Unix timestamp, in seconds). |
model | string | The original model name passed in the user request (not the actual model name used by the model service). |
choices | array | The list of candidate results, where the number of elements equals the n specified in the request. |
usage | object | Token consumption statistics. For details, see the "usage" object. |
search_info | object or null | Web search information (included when the Hunyuan/AISearch path is used; otherwise, it is null). |
Field | Type | Description |
index | integer | The index of the option in the choices array, starting from 0. |
message | object | |
finish_reason | string | The reason for generation completion. See the enumeration below. |
logprobs | object or null | Token probability information (requires logprobs=true to be set in the request). |
finish_reason Valid values:Value | Description | Handling Recommendation |
"stop" | Normal termination (the model stops on its own or matches a stop sequence). | Process as normal. |
"length" | The max_tokens / max_completion_tokens limit is reached, and the output is truncated. | Consider increasing the max_tokens value or generating content in segments. |
"tool_calls" | The model needs to call a tool. | Execute the tool and continue the request with the result as a tool message. |
"content_filter" | Content is filtered by the security policy. | Check whether the input content triggers the security rules. |
Field | Type | Description | Applicable Scenarios |
role | string | Fixed as "assistant" | All |
content | string or null | The reply text content. It may be null when tool_calls are present. | All |
reasoning_content | string | Reasoning chain/inference process content | Thinking models |
reasoning_details | array | An array of reasoning chain blocks (containing signature) | Thinking models |
tool_calls | array | Tool call list | Function Calling |
refusal | string or null | Reason for refusal | Content security filtering |
tool_calls Array elements:Field | Type | Description |
id | string | The unique ID for the tool call, in the format call_{uuid}. |
type | string | Fixed as "function". |
function.name | string | The name of the function being called. |
function.arguments | string | Function parameters (in JSON string format, which must be parsed using JSON.parse() before use). |
Field | Type | Description |
prompt_tokens | integer | The number of input tokens (including those from system, messages, and tool definitions). |
completion_tokens | integer | The number of output tokens (including reasoning tokens). |
total_tokens | integer | Total Tokens |
cache_read_tokens | integer | Number of tokens read from Prompt Cache hits (available for some models, billing can be reduced). |
cache_write_tokens | integer | Number of tokens written to Prompt Cache (available for some models). |
prompt_tokens_details | object | Breakdown of input tokens (available for some models). |
prompt_tokens_details.cached_tokens | integer | Number of cached tokens |
completion_tokens_details | object | Breakdown of output tokens (available for some models). |
completion_tokens_details.reasoning_tokens | integer | Number of tokens consumed by reasoning (OpenAI-compatible path). |
completion_tokens_details.audio_tokens | integer | Number of tokens consumed by audio output |
total_tokens = prompt_tokens + completion_tokens. completion_tokens includes reasoning chain tokens, and reasoning_tokens is a subset of them.200Content-Type: text/event-streamX-Accel-Buffering: nodata: {json}\\n\\ndata: [DONE]\\n\\n{"id": "chatcmpl-xxxxxxxxxxxxxxxxxxxxxxxx","object": "chat.completion.chunk","created": 1750924800,"model": "<your-model-name>","choices": [{"index": 0,"delta": {"role": "assistant","content": "Incremental text","reasoning_content": "Incremental reasoning chain"},"finish_reason": null}],"usage": null}
Field | Type | Description |
object | string | Fixed to "chat.completion.chunk". |
choices[].delta | object | Incremental content. |
choices[].delta.role | string | Appears only in the first chunk, with a value of "assistant". |
choices[].delta.content | string | Incremental text fragments, cumulatively concatenated into a complete response. |
choices[].delta.reasoning_content | string | Incremental reasoning chain fragment (output before content in reasoning chain mode). |
choices[].delta.reasoning_details | array | Incremental reasoning chain block (contains signature; must be fully collected after the stream ends and returned across multiple rounds). |
choices[].delta.tool_calls | array | Incremental tool calls (containing the index field to identify the array position). |
choices[].delta.search_results | array | Incremental web search results (pushed in the stream by some models). |
choices[].finish_reason | string or null | It is null during generation and becomes the termination reason upon completion. |
usage | object or null | Included only in the final formal chunk when include_usage=true. |
id, type, and function.name. Subsequent chunks only append function.arguments fragments. The client must concatenate the arguments from multiple chunks into a complete JSON string based on the index. arguments are incremental fragments. In the example, {"ci is a truncated value from the first frame, which is normal and not a format error. The following shows the first two frames:id, type, and function.name):{"delta": {"tool_calls": [{"index": 0,"id": "call_xxx","type": "function","function": {"name": "get_weather","arguments": "{\\"ci"}}]}}
{"ci, and the second frame returns ty":"Beijing"}. Concatenating these two segments yields the complete parameter {"city":"Beijing"}.function.arguments fragment):{"delta": {"tool_calls": [{"index": 0,"function": {"arguments": "ty\\":\\"Beijing\\"}"}}]}}
Scenario | Action |
Failure Before First Packet (Before HTTP 200 Header Is Written) | Returns a standard JSON error body, from which the error code can be parsed normally. If a Fallback Provider is configured, automatic fallback retry is performed. |
Error After the 200 Response Header Is Sent | The platform inserts an data: {"error":{"type":"...","message":"..."}}\\n\\n error frame into the SSE stream, and then sends a data: [DONE]\\n\\n frame to end the stream. The client must check whether the delta contains an error field. |
{"error": {"message": "<English error description>","message_zh": "<Chinese error description>","code": "<business error code>","type": "<error type>","request_id": "<request unique identifier>"}}
type is uniformly set to gateway_error.429) scenarios, the code may be returned as an integer and include the response header Retry-After (unit: seconds). When parsing error.code, the client must be compatible with both string and numeric types.data: {"error":{...}} error frame into the SSE stream and then sends a data: [DONE] frame to end the stream. The client must detect whether the incremental content contains an error field.curl -X POST "https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions" \\-H "Authorization: Bearer YOUR_API_KEY" \\-H "Content-Type: application/json" \\-d '{"model": "<your-model-name>","messages": [{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Hello, please introduce yourself."}],"temperature": 0.7,"max_tokens": 1024}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY",base_url="https://tokenhub-intl.tencentcloudmaas.com/v1",)response = client.chat.completions.create(model="<your-model-name>",messages=[{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Hello, please introduce yourself."},],temperature=0.7,max_tokens=1024,)print(response.choices[0].message.content)
import OpenAI from 'openai';const client = new OpenAI({apiKey: 'YOUR_API_KEY',baseURL: 'https://tokenhub-intl.tencentcloudmaas.com/v1',});const response = await client.chat.completions.create({model: '<your-model-name>',messages: [{ role: 'system', content: 'You are a helpful assistant.' },{ role: 'user', content: 'Hello, please introduce yourself.' },],temperature: 0.7,max_tokens: 1024,});console.log(response.choices[0].message.content);
import okhttp3.*;import com.google.gson.Gson;import java.util.*;public class BasicChat {public static void main(String[] args) throws Exception {Map<String, Object> body = new HashMap<>();body.put("model", "<your-model-name>");body.put("messages", List.of(Map.of("role", "system", "content", "You are a helpful assistant."),Map.of("role", "user", "content", "Hello, please introduce yourself.")));body.put("temperature", 0.7);body.put("max_tokens", 1024);Request request = new Request.Builder().url("https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions").header("Authorization", "Bearer YOUR_API_KEY").post(RequestBody.create(new Gson().toJson(body), MediaType.parse("application/json"))).build();try (Response response = new OkHttpClient().newCall(request).execute()) {System.out.println(response.body().string());}}}
package mainimport ("bytes""encoding/json""fmt""io""net/http")func main() {body, _ := json.Marshal(map[string]interface{}{"model": "<your-model-name>","messages": []map[string]string{{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Hello, please introduce yourself."},},"temperature": 0.7,"max_tokens": 1024,})req, _ := http.NewRequest("POST","https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions",bytes.NewBuffer(body))req.Header.Set("Authorization", "Bearer YOUR_API_KEY")req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)if err != nil {panic(err)}defer resp.Body.Close()data, _ := io.ReadAll(resp.Body)fmt.Println(string(data))}
curl -X POST "https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions" \\-H "Authorization: Bearer YOUR_API_KEY" \\-H "Content-Type: application/json" \\-d '{"model": "<your-model-name>","messages": [{"role": "user", "content": "What is the weather like in Beijing today?"}],"tools": [{"type": "function","function": {"name": "get_weather","description": "Obtain the weather information for a specified city","parameters": {"type": "object","properties": {"city": {"type": "string", "description": "City name"}},"required": ["city"]}}}],"tool_choice": "auto"}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY", base_url="https://tokenhub-intl.tencentcloudmaas.com/v1")response = client.chat.completions.create(model="<your-model-name>",messages=[{"role": "user", "content": "What is the weather like in Beijing today?"}],tools=[{"type": "function","function": {"name": "get_weather","description": "Obtain the weather information for a specified city","parameters": {"type": "object","properties": {"city": {"type": "string", "description": "City name"}},"required": ["city"],},},}],tool_choice="auto",)print(response.choices[0].message)
import OpenAI from 'openai';const client = new OpenAI({ apiKey: 'YOUR_API_KEY', baseURL: 'https://tokenhub-intl.tencentcloudmaas.com/v1' });const response = await client.chat.completions.create({model: '<your-model-name>',messages: [{ role: 'user', content: 'What is the weather like in Beijing today?' }],tools: [{type: 'function',function: {name: 'get_weather',description: 'Obtain the weather information for a specified city',parameters: {type: 'object',properties: { city: { type: 'string', description: 'City name' } },required: ['city'],},},},],tool_choice: 'auto',});console.log(response.choices[0].message);
import okhttp3.*;public class FunctionCalling {public static void main(String[] args) throws Exception {String body = """{"model": "<your-model-name>","messages": [{"role": "user", "content": "What is the weather like in Beijing today?"}],"tools": [{"type": "function","function": {"name": "get_weather","description": "Obtain the weather information for a specified city","parameters": {"type": "object","properties": {"city": {"type": "string", "description": "City name"}},"required": ["city"]}}}],"tool_choice": "auto"}""";Request request = new Request.Builder().url("https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions").header("Authorization", "Bearer YOUR_API_KEY").post(RequestBody.create(body, MediaType.parse("application/json"))).build();try (Response response = new OkHttpClient().newCall(request).execute()) {System.out.println(response.body().string());}}}
package mainimport ("fmt""io""net/http""strings")func main() {body := `{"model": "<your-model-name>","messages": [{"role": "user", "content": "What is the weather like in Beijing today?"}],"tools": [{"type": "function","function": {"name": "get_weather","description": "Obtain the weather information for a specified city","parameters": {"type": "object","properties": {"city": {"type": "string", "description": "City name"}},"required": ["city"]}}}],"tool_choice": "auto"}`req, _ := http.NewRequest("POST","https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions",strings.NewReader(body))req.Header.Set("Authorization", "Bearer YOUR_API_KEY")req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)if err != nil {panic(err)}defer resp.Body.Close()data, _ := io.ReadAll(resp.Body)fmt.Println(string(data))}
curl -X POST "https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions" \\-H "Authorization: Bearer YOUR_API_KEY" \\-H "Content-Type: application/json" \\-d '{"model": "<your-model-name>","messages": [{"role": "user", "content": "Prove that the square root of 2 is an irrational number."}],"stream": true,"stream_options": {"include_usage": true},"thinking": {"type": "enabled", "budget_tokens": 8000},"max_tokens": 4096}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY", base_url="https://tokenhub-intl.tencentcloudmaas.com/v1")stream = client.chat.completions.create(model="<your-model-name>",messages=[{"role": "user", "content": "Prove that the square root of 2 is an irrational number"}],stream=True,stream_options={"include_usage": True},extra_body={"thinking": {"type": "enabled", "budget_tokens": 8000}},max_tokens=4096,)for chunk in stream:if chunk.choices and chunk.choices[0].delta.content:print(chunk.choices[0].delta.content, end="", flush=True)
import OpenAI from 'openai';const client = new OpenAI({ apiKey: 'YOUR_API_KEY', baseURL: 'https://tokenhub-intl.tencentcloudmaas.com/v1' });const stream = await client.chat.completions.create({model: '<your-model-name>',messages: [{ role: 'user', content: 'Prove that the square root of 2 is an irrational number' }],stream: true,stream_options: { include_usage: true },// thinking is a platform extension parameterthinking: { type: 'enabled', budget_tokens: 8000 },max_tokens: 4096,});for await (const chunk of stream) {const delta = chunk.choices[0]?.delta?.content;if (delta) process.stdout.write(delta);}
import okhttp3.*;import java.io.BufferedReader;import java.io.InputStreamReader;public class StreamThinking {public static void main(String[] args) throws Exception {String body = """{"model": "<your-model-name>","messages": [{"role": "user", "content": "Prove that the square root of 2 is an irrational number."}],"stream": true,"stream_options": {"include_usage": true},"thinking": {"type": "enabled", "budget_tokens": 8000},"max_tokens": 4096}""";Request request = new Request.Builder().url("https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions").header("Authorization", "Bearer YOUR_API_KEY").post(RequestBody.create(body, MediaType.parse("application/json"))).build();try (Response response = new OkHttpClient().newCall(request).execute();BufferedReader reader = new BufferedReader(new InputStreamReader(response.body().byteStream()))) {String line;while ((line = reader.readLine()) != null) {if (!line.isEmpty()) System.out.println(line);}}}}
package mainimport ("bufio""fmt""net/http""strings")func main() {body := `{"model": "<your-model-name>","messages": [{"role": "user", "content": "Prove that the square root of 2 is an irrational number."}],"stream": true,"stream_options": {"include_usage": true},"thinking": {"type": "enabled", "budget_tokens": 8000},"max_tokens": 4096}`req, _ := http.NewRequest("POST","https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions",strings.NewReader(body))req.Header.Set("Authorization", "Bearer YOUR_API_KEY")req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)if err != nil {panic(err)}defer resp.Body.Close()scanner := bufio.NewScanner(resp.Body)for scanner.Scan() {if line := scanner.Text(); line != "" {fmt.Println(line)}}}
curl -X POST "https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions" \\-H "Authorization: Bearer YOUR_API_KEY" \\-H "Content-Type: application/json" \\-d '{"model": "<your-model-name>","messages": [{"role": "user","content": [{"type": "text", "text": "Please describe the content of this picture."},{"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}]}]}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY", base_url="https://tokenhub-intl.tencentcloudmaas.com/v1")response = client.chat.completions.create(model="<your-model-name>",messages=[{"role": "user","content": [{"type": "text", "text": "Please describe the content of this picture."},{"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}},],}],)print(response.choices[0].message.content)
import OpenAI from 'openai';const client = new OpenAI({ apiKey: 'YOUR_API_KEY', baseURL: 'https://tokenhub-intl.tencentcloudmaas.com/v1' });const response = await client.chat.completions.create({model: '<your-model-name>',messages: [{role: 'user',content: [{ type: 'text', text: 'Please describe the content of this picture.' },{ type: 'image_url', image_url: { url: 'https://example.com/image.jpg' } },],},],});console.log(response.choices[0].message.content);
import okhttp3.*;public class Multimodal {public static void main(String[] args) throws Exception {String body = """{"model": "<your-model-name>","messages": [{"role": "user","content": [{"type": "text", "text": "Please describe the content of this picture."},{"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}]}]}""";Request request = new Request.Builder().url("https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions").header("Authorization", "Bearer YOUR_API_KEY").post(RequestBody.create(body, MediaType.parse("application/json"))).build();try (Response response = new OkHttpClient().newCall(request).execute()) {System.out.println(response.body().string());}}}
package mainimport ("fmt""io""net/http""strings")func main() {body := `{"model": "<your-model-name>","messages": [{"role": "user","content": [{"type": "text", "text": "Please describe the content of this picture."},{"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}]}]}`req, _ := http.NewRequest("POST","https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions",strings.NewReader(body))req.Header.Set("Authorization", "Bearer YOUR_API_KEY")req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)if err != nil {panic(err)}defer resp.Body.Close()data, _ := io.ReadAll(resp.Body)fmt.Println(string(data))}
curl -X POST "https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions" \\-H "Authorization: Bearer YOUR_API_KEY" \\-H "Content-Type: application/json" \\-d '{"model": "<your-model-name>","messages": [{"role": "user", "content": "Analyze the time complexity of this algorithm."},{"role": "assistant","content": "The time complexity of this algorithm is O(n log n).","reasoning_details": [{"type": "thinking","content": "Let me analyze this: the outer loop iterates n times...","signature": "EqoBCkgIARgCIkD..."}]},{"role": "user", "content": "How can it be optimized to O(n)?"}],"thinking": {"type": "enabled", "budget_tokens": 5000}}'
from openai import OpenAIclient = OpenAI(api_key="YOUR_API_KEY", base_url="https://tokenhub-intl.tencentcloudmaas.com/v1")response = client.chat.completions.create(model="<your-model-name>",messages=[{"role": "user", "content": "Analyze the time complexity of this algorithm."},{"role": "assistant","content": "The time complexity of this algorithm is O(n log n).","reasoning_details": [{"type": "thinking","content": "Let me analyze this: the outer loop iterates n times...","signature": "EqoBCkgIARgCIkD...",}],},{"role": "user", "content": "How can it be optimized to O(n)?"},],extra_body={"thinking": {"type": "enabled", "budget_tokens": 5000}},)print(response.choices[0].message.content)
import OpenAI from 'openai';const client = new OpenAI({ apiKey: 'YOUR_API_KEY', baseURL: 'https://tokenhub-intl.tencentcloudmaas.com/v1' });const response = await client.chat.completions.create({model: '<your-model-name>',messages: [{ role: 'user', content: 'Analyze the time complexity of this algorithm.' },{role: 'assistant',content: 'The time complexity of this algorithm is O(n log n).',reasoning_details: [{type: 'thinking',content: 'Let me analyze this: the outer loop iterates n times...',signature: 'EqoBCkgIARgCIkD...',},],},{ role: 'user', content: 'How can it be optimized to O(n)?' },],// thinking is a platform extension parameterthinking: { type: 'enabled', budget_tokens: 5000 },});console.log(response.choices[0].message.content);
import okhttp3.*;public class MultiTurnThinking {public static void main(String[] args) throws Exception {String body = """{"model": "<your-model-name>","messages": [{"role": "user", "content": "Analyze the time complexity of this algorithm."},{"role": "assistant","content": "The time complexity of this algorithm is O(n log n).","reasoning_details": [{"type": "thinking","content": "Let me analyze this: the outer loop iterates n times...","signature": "EqoBCkgIARgCIkD..."}]},{"role": "user", "content": "How can it be optimized to O(n)?"}],"thinking": {"type": "enabled", "budget_tokens": 5000}}""";Request request = new Request.Builder().url("https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions").header("Authorization", "Bearer YOUR_API_KEY").post(RequestBody.create(body, MediaType.parse("application/json"))).build();try (Response response = new OkHttpClient().newCall(request).execute()) {System.out.println(response.body().string());}}}
package mainimport ("fmt""io""net/http""strings")func main() {body := `{"model": "<your-model-name>","messages": [{"role": "user", "content": "Analyze the time complexity of this algorithm."},{"role": "assistant","content": "The time complexity of this algorithm is O(n log n).","reasoning_details": [{"type": "thinking","content": "Let me analyze this: the outer loop iterates n times...","signature": "EqoBCkgIARgCIkD..."}]},{"role": "user", "content": "How can it be optimized to O(n)?"}],"thinking": {"type": "enabled", "budget_tokens": 5000}}`req, _ := http.NewRequest("POST","https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions",strings.NewReader(body))req.Header.Set("Authorization", "Bearer YOUR_API_KEY")req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)if err != nil {panic(err)}defer resp.Body.Close()data, _ := io.ReadAll(resp.Body)fmt.Println(string(data))}
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan