


YOUR_API_KEY 替换为您真实的 API KEY。model 字段,更换您需要调用的模型,各模型对应 model 值可参见 模型列表 中的 model(调用参数)。# 请将 YOUR_API_KEY 替换为您在前面步骤创建的 API KEY# 请在 model 字段中更换您需要体验的模型名称curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions' \\-H 'Authorization: Bearer YOUR_API_KEY' \\-H 'Content-Type: application/json' \\-d '{"model": "deepseek-v3.2","messages": [{"role": "user", "content": "你好"}],"stream": true}'
from openai import OpenAIclient = OpenAI(# 请将 YOUR_API_KEY 替换为您在前面步骤创建的 API KEYapi_key="YOUR_API_KEY",base_url="https://tokenhub-intl.tencentcloudmaas.com/v1")response = client.chat.completions.create(# 请在 model 字段中更换您需要体验的模型名称model="deepseek-v3.2",messages=[{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "你好,请介绍一下你自己"}])print(response.choices[0].message.content)
import OpenAI from 'openai';const client = new OpenAI({// 请将 YOUR_API_KEY 替换为您在前面步骤创建的 API KEYapiKey: 'YOUR_API_KEY',baseURL: 'https://tokenhub-intl.tencentcloudmaas.com/v1',});async function main() {const response = await client.chat.completions.create({// 请在 model 字段中更换您需要体验的模型名称model: 'deepseek-v3.2',messages: [{ role: 'system', content: 'You are a helpful assistant.' },{ role: 'user', content: '你好,请介绍一下你自己' },],});console.log(response.choices[0].message.content);}main();
import java.net.http.*;import java.net.URI;public class MaaSExample {public static void main(String[] args) throws Exception {// 请将 YOUR_API_KEY 替换为您在前面步骤创建的 API KEYString apiKey = "YOUR_API_KEY";// 请在 model 字段中更换您需要体验的模型名称String body = """{"model": "deepseek-v3.2","messages": [{"role": "user", "content": "你好"}]}""";HttpRequest request = HttpRequest.newBuilder().uri(URI.create("https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions")).header("Authorization", "Bearer " + apiKey).header("Content-Type", "application/json").POST(HttpRequest.BodyPublishers.ofString(body)).build();HttpClient client = HttpClient.newHttpClient();HttpResponse<String> response = client.send(request,HttpResponse.BodyHandlers.ofString());System.out.println(response.body());}}
package mainimport ("bytes""encoding/json""fmt""io""net/http")func main() {// 请将 YOUR_API_KEY 替换为您在前面步骤创建的 API KEYapiKey := "YOUR_API_KEY"body := map[string]interface{}{// 请在 model 字段中更换您需要体验的模型名称"model": "deepseek-v3.2","messages": []map[string]string{{"role": "user", "content": "你好"},},}jsonBody, _ := json.Marshal(body)req, _ := http.NewRequest("POST","https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions",bytes.NewBuffer(jsonBody))req.Header.Set("Authorization", "Bearer "+apiKey)req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)if err != nil {panic(err)}defer resp.Body.Close()result, _ := io.ReadAll(resp.Body)fmt.Println(string(result))}
文档反馈