智能体对话
curl --request POST \
--url https://open.bigmodel.cn/api/v1/agents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "user",
"content": "请帮我翻译这段文字:Hello World"
}
],
"stream": false,
"custom_variables": {
"source_lang": "en",
"target_lang": "zh-CN",
"strategy": "general",
"strategy_config": {
"general": {
"suggestion": "专业技术文档翻译风格"
}
}
}
}
'import requests
url = "https://open.bigmodel.cn/api/v1/agents"
payload = {
"messages": [
{
"role": "user",
"content": "请帮我翻译这段文字:Hello World"
}
],
"stream": False,
"custom_variables": {
"source_lang": "en",
"target_lang": "zh-CN",
"strategy": "general",
"strategy_config": { "general": { "suggestion": "专业技术文档翻译风格" } }
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{role: 'user', content: '请帮我翻译这段文字:Hello World'}],
stream: false,
custom_variables: {
source_lang: 'en',
target_lang: 'zh-CN',
strategy: 'general',
strategy_config: {general: {suggestion: '专业技术文档翻译风格'}}
}
})
};
fetch('https://open.bigmodel.cn/api/v1/agents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://open.bigmodel.cn/api/v1/agents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"请帮我翻译这段文字:Hello World\"\n }\n ],\n \"stream\": false,\n \"custom_variables\": {\n \"source_lang\": \"en\",\n \"target_lang\": \"zh-CN\",\n \"strategy\": \"general\",\n \"strategy_config\": {\n \"general\": {\n \"suggestion\": \"专业技术文档翻译风格\"\n }\n }\n }\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://open.bigmodel.cn/api/v1/agents"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"请帮我翻译这段文字:Hello World\"\n }\n ],\n \"stream\": false,\n \"custom_variables\": {\n \"source_lang\": \"en\",\n \"target_lang\": \"zh-CN\",\n \"strategy\": \"general\",\n \"strategy_config\": {\n \"general\": {\n \"suggestion\": \"专业技术文档翻译风格\"\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://open.bigmodel.cn/api/v1/agents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'messages' => [
[
'role' => 'user',
'content' => '请帮我翻译这段文字:Hello World'
]
],
'stream' => false,
'custom_variables' => [
'source_lang' => 'en',
'target_lang' => 'zh-CN',
'strategy' => 'general',
'strategy_config' => [
'general' => [
'suggestion' => '专业技术文档翻译风格'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "<string>",
"agent_id": "<string>",
"conversation_id": "<string>",
"async_id": "<string>",
"choices": [
{
"index": 123,
"messages": [
{
"role": "assistant",
"content": "<string>"
}
],
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Agent API
智能体对话
与智能体进行对话交互。支持同步和流式调用,提供智能体的专业能力。见 智能体文档。点击 Try it 按钮可快速试用。
POST
/
v1
/
agents
智能体对话
curl --request POST \
--url https://open.bigmodel.cn/api/v1/agents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "user",
"content": "请帮我翻译这段文字:Hello World"
}
],
"stream": false,
"custom_variables": {
"source_lang": "en",
"target_lang": "zh-CN",
"strategy": "general",
"strategy_config": {
"general": {
"suggestion": "专业技术文档翻译风格"
}
}
}
}
'import requests
url = "https://open.bigmodel.cn/api/v1/agents"
payload = {
"messages": [
{
"role": "user",
"content": "请帮我翻译这段文字:Hello World"
}
],
"stream": False,
"custom_variables": {
"source_lang": "en",
"target_lang": "zh-CN",
"strategy": "general",
"strategy_config": { "general": { "suggestion": "专业技术文档翻译风格" } }
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{role: 'user', content: '请帮我翻译这段文字:Hello World'}],
stream: false,
custom_variables: {
source_lang: 'en',
target_lang: 'zh-CN',
strategy: 'general',
strategy_config: {general: {suggestion: '专业技术文档翻译风格'}}
}
})
};
fetch('https://open.bigmodel.cn/api/v1/agents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://open.bigmodel.cn/api/v1/agents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"请帮我翻译这段文字:Hello World\"\n }\n ],\n \"stream\": false,\n \"custom_variables\": {\n \"source_lang\": \"en\",\n \"target_lang\": \"zh-CN\",\n \"strategy\": \"general\",\n \"strategy_config\": {\n \"general\": {\n \"suggestion\": \"专业技术文档翻译风格\"\n }\n }\n }\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://open.bigmodel.cn/api/v1/agents"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"请帮我翻译这段文字:Hello World\"\n }\n ],\n \"stream\": false,\n \"custom_variables\": {\n \"source_lang\": \"en\",\n \"target_lang\": \"zh-CN\",\n \"strategy\": \"general\",\n \"strategy_config\": {\n \"general\": {\n \"suggestion\": \"专业技术文档翻译风格\"\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://open.bigmodel.cn/api/v1/agents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'messages' => [
[
'role' => 'user',
'content' => '请帮我翻译这段文字:Hello World'
]
],
'stream' => false,
'custom_variables' => [
'source_lang' => 'en',
'target_lang' => 'zh-CN',
'strategy' => 'general',
'strategy_config' => [
'general' => [
'suggestion' => '专业技术文档翻译风格'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "<string>",
"agent_id": "<string>",
"conversation_id": "<string>",
"async_id": "<string>",
"choices": [
{
"index": 123,
"messages": [
{
"role": "assistant",
"content": "<string>"
}
],
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Body
application/json
智能体 ID
Available options:
general_translation, slides_glm_agent, ai_drawing_agent, receipt_recognition_agent, clothes_recognition_agent, intelligent_education_solve_agent, vidu_template_agent 会话消息体列表。
Minimum array length:
1Show child attributes
Show child attributes
是否选择流式输出。当一个 agent 提供流式与非流式两种输出方式时,可根据需求选择一种。
智能体扩展参数。根据不同智能体的需求提供相应的参数配置。
- 通用翻译智能体
- 自定义智能体扩展
Show child attributes
Show child attributes
Example:
{
"source_lang": "en",
"target_lang": "zh-CN",
"strategy": "general",
"strategy_config": { "general": { "suggestion": "专业技术文档翻译风格" } }
}
Was this page helpful?
⌘I