Skip to content

OpenAI API 接口

该模型适配于 OpenAI 端侧接口标准

Base Url: https://maas-openapi.wanjiedata.com/api/v1

获取 API KEYhttps://www.wjark.com/center/api-key

说明:使用 GPT 系列模型时,以下字段要么不设置,要么严格按照以下要求设置,如

shell
curl --location --request POST 'https://maas-openapi.wanjiedata.com/api/v1/chat/completions' \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "'$gpt_MODEL'",
    "messages": [{"role": "user", "content": "请用一句话介绍自己"}],
    "stream": false,
    "temperature": 1,
    "top_p": 1,
    "top_n": 1,
    "presence_penalty": 0,
    "frequency_penalty": 0
}'

获取模型列表

  • 获取已经授权的模型列表
shell
curl https://maas-openapi.wanjiedata.com/api/v1/models \
  -H "Authorization: Bearer $API_KEY"
python
import requests
API_KEY = "<你的 API KEY>"
url = "https://maas-openapi.wanjiedata.com/api/v1/models"
headers = {
    "Authorization": f"Bearer {API_KEY}"
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.json())
javascript
import axios from 'axios';

const apiKey = '<你的 API KEY>';

async function getModels() {
  try {
    const response = await axios.get('https://maas-openapi.wanjiedata.com/api/v1/models', {
      headers: { Authorization: `Bearer ${apiKey}` }
    });
    console.log('模型列表:', response.data);
  } catch (error) {
    console.error('请求失败:', error.response ? error.response.data : error.message);
  }
}

getModels();
csharp
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
   static async Task Main()
   {
       var client = new HttpClient();
       client.DefaultRequestHeaders.Add("Authorization", "Bearer <你的 API KEY>");
       var response = await client.GetStringAsync("https://maas-openapi.wanjiedata.com/api/v1/models");
       Console.WriteLine(response);
   }
}

响应示例

shell
[
    {
        "id": "gpt-5.6-terra-plus",
        "object": "model",
        "created": 1785379812,
        "owned_by": "organization"
    },
    {
        "id": "gpt-5.6-luna-plus",
        "object": "model",
        "created": 1785379812,
        "owned_by": "organization"
    }
]
python
{
  'data': [
    {'id': 'gpt-5.6-sol-plus', 'object': 'model', 'created': 1785379812, 'owned_by': 'organization'},
    {'id': 'hy3', 'object': 'model', 'created': 1785379812, 'owned_by': 'organization'},
    {'id': 'hunyuan-role-latest', 'object': 'model', 'created': 1785379812, 'owned_by': 'organization'}
  ],
  'object': 'list'
}
javascript
模型列表: {
  data: [
    {"id":"gpt-5.6-sol-plus","object":"model","created":1785379812,"owned_by":"organization"},
    {"id":"gpt-5.6-terra-plus","object":"model","created":1785379812,"owned_by":"organization"},
    {"id":"gpt-5.6-luna-plus","object":"model","created":1785379812,"owned_by":"organization"}
  ],
  object: 'list'
}
csharp
{"data":[{"id":"claude-opus-5","object":"model","created":1785379812,"owned_by":"organization"},
{"id":"gpt-5.5-plus","object":"model","created":1785379812,"owned_by":"organization"},
{"id":"gpt-5.6-sol-plus","object":"model","created":1785379812,"owned_by":"organization"},
{"id":"gpt-5.6-terra-plus","object":"model","created":1785379812,"owned_by":"organization"},
{"id":"gpt-5.6-luna-plus","object":"model","created":1785379812,"owned_by":"organization"}],"object":"list"}

基础文本对话

shell
POST /v1/chat/completions

注:请求 hunyuan-role-latest、hy3-preview、hy3、hunyuan-vision-1.5-instruct、hunyuan-t1-vision-20250916 模型时,字段 seed 必须为正整数

hunyuan 模型请求示例:

shell
curl --location --request POST 'https://maas-openapi.wanjiedata.com/api/v1/chat/completions' \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "'$hunyuan_MODEL'",
    "messages": [{"role": "user", "content": "请用一句话介绍自己"}],
    "stream": false,
    "seed": 1
}'

非流式请求示例

shell
curl --location --request POST 'https://maas-openapi.wanjiedata.com/api/v1/chat/completions' \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "'$MODEL'",
    "messages": [{"role": "user", "content": "请用一句话介绍自己"}],
    "stream": false
}'
python
import requests
url = "https://maas-openapi.wanjiedata.com/api/v1/chat/completions"
headers = {
    "Authorization": "Bearer {}".format("API_KEY"),  # 请将 API_KEY 替换为你的实际密钥
    "Content-Type": "application/json"
}
data = {
    "model": "MODEL",  # 请将 MODEL 替换为OpenAI 端侧接口标准适配模型
    "messages": [{"role": "user", "content": "请用一句话介绍自己"}],
    "stream": False
}
response = requests.post(url, headers=headers, json=data)
print(response.text)
javascript
fetch('https://maas-openapi.wanjiedata.com/api/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer 你的APIKey',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: ' OpenAI 接口标准适用模型',
    messages: [{ role: 'user', content: '请用一句话介绍自己' }],
    stream: false
  })
})
  .then(res => res.json())
  .then(data => {
    const reply = data.choices?.[0]?.message?.content || '';
    console.log('回复内容:', reply);
    console.log(data);
  })
  .catch(console.error);

非流式响应示例

shell
{
    "id": "chatcmpl-Cct0tR2gzMsixFQns4Z0s3LbmEfek",
    "object": "chat.completion",
    "created": 1763383971,
    "model": "GPT-4.1",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "我是由 OpenAI 开发的智能助手,能够帮助你解答问题、提供信息和支持各种文本写作需求。",
                "tool_calls": null
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 13,
        "completion_tokens": 27,
        "total_tokens": 40
    },
    "system_fingerprint": "fp_f99638a8d7"
}
python
{
  "id":"chatcmpl-Ccj1HgXyB5HQb6AT4kxA2Gv9iQkwB","object":"chat.completion",
  "created":1763345555,
  "model":"GPT-4.1",
  "choices":[{
    "index":0,
    "message":{
      "role":"assistant","content":"我是 ChatGPT,一款由 OpenAI 开发的智能对话 AI 助手,很高兴为你提供帮助!","tool_calls":null
      },
      "finish_reason":"stop"}
      ],
      "usage":{"prompt_tokens":13,"completion_tokens":24,"total_tokens":37},
      "system_fingerprint":"fp_f99638a8d7"}
javascript
回复内容: 我是ChatGPT,一款由OpenAI开发的智能对话助手,能够帮助你解答问题、提供建议和创作内容。
{
  id: 'chatcmpl-CckB5i7otsyx3qxWJiEZdGYAM3iVW',
  object: 'chat.completion',
  created: 1763350007,
  model: 'GPT-4.1',
  choices: [ { index: 0, message: [Object], finish_reason: 'stop' } ],
  usage: { prompt_tokens: 13, completion_tokens: 30, total_tokens: 43 },
  system_fingerprint: 'fp_f99638a8d7'
}

流式请求示例

注:qwq-plus 模型只能使用流式请求,即 stream 字段必须设置为 true

shell
# 授权模型名称:在授权模型列表中模型名称复制名称获取。
curl --location --request POST 'https://maas-openapi.wanjiedata.com/api/v1/chat/completions' \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "'$MODEL'",
    "messages": [{"role": "user", "content": "请用一句话介绍自己"}],
    "stream": true
}'
python
import requests

url = "https://maas-openapi.wanjiedata.com/api/v1/chat/completions"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

data = {
    "model": "$MODEL",
    "messages": [
        {"role": "user", "content": "请用一句话介绍自己"}
    ],
    "stream": True
}

response = requests.post(url, headers=headers, json=data)
print(response.text)
javascript
fetch('https://maas-openapi.wanjiedata.com/api/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer $API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: '$MODEL',
    messages: [{ role: 'user', content: '请用一句话介绍自己' }],
    stream: true
  })
})
  .then(res => res.body)
  .then(body => {
    const reader = body.getReader();
    const decoder = new TextDecoder();
    function read() {
      reader.read().then(({ done, value }) => {
        if (done) return;
        console.log(decoder.decode(value));
        read();
      });
    }
    read();
  })
  .catch(console.error);

流式响应示例

shell
{
    "id": "chatcmpl-CdAoolTjqXY1Ip5sMFPN4buGPgW1V",
    "object": "chat.completion.chunk",
    "created": 1763452414,
    "model": "GPT-4.1",
    "system_fingerprint": "fp_f99638a8d7",
    "choices": [],
    "usage": {
        "prompt_tokens": 13,
        "completion_tokens": 30,
        "total_tokens": 43,
        "prompt_tokens_details": {
            "cached_tokens": 0,
            "audio_tokens": 0
        },
        "completion_tokens_details": {
            "reasoning_tokens": 0,
            "audio_tokens": 0,
            "accepted_prediction_tokens": 0,
            "rejected_prediction_tokens": 0
        }
    }
}
python
id: 0
data: {"id":"chatcmpl-CdBkqaNlBzKQS31mZAMEBduz1WuVO","object":"chat.completion.chunk","created":1763456012,"model":"GPT-4.1","system_fingerprint":"fp_433e8c8649","choices":[{"index":0,"delta":{"role":"assistant","content":null,"reasoning_content":"","refusal":null,"tool_calls":null},"logprobs":null,"finish_reason":null}],"usage":null}

id: 1
data: {"id":"chatcmpl-CdBkqaNlBzKQS31mZAMEBduz1WuVO","object":"chat.completion.chunk","created":1763456012,"model":"GPT-4.1","system_fingerprint":"fp_433e8c8649","choices":[{"index":0,"delta":{"role":"assistant","content":"ææ¯","reasoning_content":"","refusal":null,"tool_calls":null},"logprobs":null,"finish_reason":null}],"usage":null}
...
...
id: 26
data: {"id":"chatcmpl-CdBkqaNlBzKQS31mZAMEBduz1WuVO","object":"chat.completion.chunk","created":1763456012,"model":"GPT-4.1","system_fingerprint":"fp_433e8c8649","choices":[],"usage":{"prompt_tokens":13,"completion_tokens":24,"total_tokens":37,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}

id: 27
data: [DONE]
javascript
id: 0
data: {"id":"chatcmpl-CdBmDOXRAJjS3yNOwWWKdFPseydfV","object":"chat.completion.chunk","created":1763456097,"model":"GPT-4.1","system_fingerprint":"fp_f99638a8d7","choices":[{"index":0,"delta":{"role":"assistant","content":null,"reasoning_content":"","refusal":null,"tool_calls":null},"logprobs":null,"finish_reason":null}],"usage":null}

id: 1
data: {"id":"chatcmpl-CdBmDOXRAJjS3yNOwWWKdFPseydfV","object":"chat.completion.chunk","created":1763456097,"model":"GPT-4.1","system_fingerprint":"fp_f99638a8d7","choices":[{"index":0,"delta":{"role":"assistant","content":"我是","reasoning_content":"","refusal":null,"tool_calls":null},"logprobs":null,"finish_reason":null}],"usage":null}
...
...
id: 27
data: {"id":"chatcmpl-CdBmDOXRAJjS3yNOwWWKdFPseydfV","object":"chat.completion.chunk","created":1763456097,"model":"GPT-4.1","system_fingerprint":"fp_f99638a8d7","choices":[],"usage":{"prompt_tokens":13,"completion_tokens":26,"total_tokens":39,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}

id: 28
data: [DONE]

Open AI 文生图接口

shell
POST /v1/images/generations
shell
curl --location --request POST 'https://maas-openapi.wanjiedata.com/api/v1/images/generations' \
--header "Authorization: Bearer $API_KEY"  \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "'$MODEL'",
  "prompt": "graphic of a Harley Davidson bike",
  "n": 1,
  "size": "1024x1024",
  "responseFormat": "url",
  "quality": "standard"
}'
python
import requests
API_KEY = "<你的 API KEY>"
MODEL = "<你的授权文生图模型名称>"
url = "https://maas-openapi.wanjiedata.com/api/v1/images/generations"
headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}
payload = {
    "model": MODEL,
    "prompt": "graphic of a Harley Davidson bike",
    "n": 1,
    "size": "1024x1024",
    "responseFormat": "url",
    "quality": "standard"
}
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
    result = response.json()
    print(result) 
else:
    print("请求失败:", response.status_code)
    print(response.text)
javascript
import axios from 'axios';

const apiKey = '<你的 API KEY>'; 
const model = '<你的授权文生图模型名称>'; 
const url = 'https://maas-openapi.wanjiedata.com/api/v1/images/generations';

async function generateImage() {
  const headers = {
    Authorization: `Bearer ${apiKey}`,
    'Content-Type': 'application/json'
  };
  const data = {
    model,
    prompt: 'graphic of a Harley Davidson bike',
    n: 1,
    size: '1024x1024',
    responseFormat: 'url'
  };

  try {
    const res = await axios.post(url, data, { headers });
    console.log(res.data.data[0].url); 
  } catch (err) {
    console.error('请求失败:', err.message);
  }
}

generateImage();
csharp
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class P {
    static async Task Main() {
        var c = new HttpClient();
        c.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");
        var d = new StringContent(@"{
            ""model"":""<MODEL>"",
            ""prompt"":""graphic of a Harley Davidson bike"",
            ""n"":1,
            ""size"":""1024x1024"",
            ""responseFormat"":""url"",
            ""quality"":""standard"",
            ""style"":""vivid""
        }", Encoding.UTF8, "application/json");
        var r = await c.PostAsync("https://maas-openapi.wanjiedata.com/api/v1/images/generations", d);
        System.Console.WriteLine(await r.Content.ReadAsStringAsync());
    }
}

响应示例

shell
{
    "created": 1762221608,
    "data": [
        {
            "url": "https://rgw.wanjiedata.com/maas-public-bucket/2025/11/04/c3fe6bdd3a601f90c4d1e33e961e064f.jpg"
        }
    ],
    "usage": {
        "input_tokens_details": {}
    }
}
python
{
    'created': 1762220795, 
    'data': [{'url': 'https://rgw.wanjiedata.com/maas-public-bucket/2025/11/04/a920b1331c7c5676624e38cbc10d8b43.jpg'}],
    'usage': {'input_tokens_details': {}
    }
}
javascript
https://rgw.wanjiedata.com/maas-public-bucket/2025/11/04/0d4e5bc27fe7b76a1544a36d75f4c1da.jpg
csharp
{"created":1762414008,"data":[{"url":"https://rgw.wanjiedata.com/maas-public-bucket/2025/11/06/6c6eaaa374eb4be4a629b3adff530412.jpg"}],"usage":{"input_tokens_details":{}}}

注意:如果使用 gpt 模型生成图片,如 gpt-image-2-pool、gpt-image-2 等模型则返回的是 base 64编码,需要自行转成图片

shell
{
    "created": 1777428796,
    "data": [
        {
            "b64_json": $base64编码
        }
    ],
    "usage": {
        "total_tokens": 772,
        "input_tokens": 7,
        "output_tokens": 765,
        "input_tokens_details": {}
    }
}

文生图接口参数说明见 OpenAI API Create image

Open AI 图片编辑

shell
POST /v1/images/edits
shell
curl --location --request POST 'https://maas-openapi.wanjiedata.com/api/v1/images/edits' \
--header 'Authorization: Bearer $APIKEY' \
--form 'model="gpt-image-2-pool"' \
--form 'prompt="$你的图片修改提示词"' \
--form 'image=@"$你的图片文件目录"'  //支持多张图片,将这行按需求复制几行即可
python
import requests
import json
import os

def image_edit(
    api_key: str,
    prompt: str,
    image_paths: list,
    model: str = "gpt-image-2-pool"
) -> dict:
    """
    图片编辑接口
    
    :param api_key:      API认证Key
    :param prompt:       图片编辑提示词
    :param image_paths:  图片文件路径列表(支持多张)
    :param model:        使用的模型
    :return:             API响应结果
    """
    url = "https://maas-openapi.wanjiedata.com/api/v1/images/edits"

    headers = {
        "Authorization": f"Bearer {api_key}"
    }

    data = {
        'model': model,
        'prompt': prompt
    }

    # 构建多张图片的files列表
    files = []
    file_handles = []  # 用于最后统一关闭文件

    try:
        for image_path in image_paths:
            if not os.path.exists(image_path):
                print(f"⚠️  文件不存在: {image_path}")
                continue

            file_name = os.path.basename(image_path)

            # 根据后缀判断MIME类型
            ext = file_name.lower().split('.')[-1]
            mime_map = {
                'jpg':  'image/jpeg',
                'jpeg': 'image/jpeg',
                'png':  'image/png',
                'gif':  'image/gif',
                'webp': 'image/webp'
            }
            mime_type = mime_map.get(ext, 'image/jpeg')

            f = open(image_path, 'rb')
            file_handles.append(f)
            files.append(('image', (file_name, f, mime_type)))
            print(f"📎 已添加图片: {file_name} ({mime_type})")

        if not files:
            print("❌ 没有有效的图片文件,请检查路径")
            return None

        print(f"\n🚀 开始请求,共上传 {len(files)} 张图片...")
        response = requests.post(
            url,
            headers=headers,
            files=files,
            data=data,
            timeout=120  # 图片处理时间较长,设置较大超时
        )
        response.raise_for_status()

        return response.json()

    except requests.exceptions.Timeout:
        print("❌ 请求超时,请重试")
        return None
    except requests.exceptions.ConnectionError:
        print("❌ 网络连接错误,请检查网络")
        return None
    except requests.exceptions.HTTPError as e:
        print(f"❌ HTTP错误: {e.response.status_code} - {e.response.text}")
        return None
    except requests.exceptions.RequestException as e:
        print(f"❌ 请求异常: {e}")
        return None

    finally:
        # 确保所有文件句柄都被关闭
        for f in file_handles:
            f.close()
        print("📁 文件句柄已关闭")


if __name__ == "__main__":
    # ===== 配置参数 =====
    API_KEY = "$APIKEY"          # 替换为你的实际API Key
    PROMPT  = "$你的图片修改提示词"

    # 图片路径列表,支持多张,按需添加
    IMAGE_PATHS = [
        "path/to/image1.jpg",       # 第1张图片
        "path/to/image2.png",       # 第2张图片
        "path/to/image3.jpg",       # 第3张图片(按需增减)
    ]

    # 调用函数
    result = image_edit(
        api_key=API_KEY,
        prompt=PROMPT,
        image_paths=IMAGE_PATHS
    )

    if result:
        print("\n✅ 请求成功!")
        print(json.dumps(result, indent=2, ensure_ascii=False))
javascript
import axios from 'axios';
import FormData from 'form-data';
import fs from 'fs';

async function main() {
    try {
        const form = new FormData();
        form.append('model', 'gpt-image-2-pool');
        form.append('prompt', '$你的图片修改提示词');
        
        // 添加图片,多张图片就复制几行
        form.append('image', fs.createReadStream('./图片1.jpg'));
        form.append('image', fs.createReadStream('./图片2.jpg'));
        form.append('image', fs.createReadStream('./图片3.jpg'));

        const response = await axios.post(
            'https://maas-openapi.wanjiedata.com/api/v1/images/edits',
            form,
            {
                headers: {
                    ...form.getHeaders(),
                    'Authorization': 'Bearer $APIKEY'
                }
            }
        );

        console.log('结果:', JSON.stringify(response.data, null, 2));

    } catch (error) {
        console.error('错误:', error.message);
        if (error.response) {
            console.error('响应状态:', error.response.status);
            console.error('响应数据:', error.response.data);
        }
    }
}

main();
csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

// ===== 配置区域 =====
string apiKey = "$APIKEY";
string prompt = "$你的图片修改提示词";
string model = "gpt-image-2-pool";

// 图片文件路径(支持多张,继续添加即可)
string[] imagePaths = new[]
{
    @"D:\images\image1.jpg",
    @"D:\images\image2.jpg",
    // @"D:\images\image3.jpg",  // 按需添加
};
// ====================

var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue(apiKey); // 注意:原curl没有Bearer,直接用key

using var formData = new MultipartFormDataContent();

// 添加 model 字段
formData.Add(new StringContent(model), "model");

// 添加 prompt 字段
formData.Add(new StringContent(prompt), "prompt");

// 添加图片文件(支持多张)
foreach (var imagePath in imagePaths)
{
    if (!System.IO.File.Exists(imagePath))
    {
        Console.WriteLine($"文件不存在: {imagePath}");
        return;
    }

    var imageBytes = await System.IO.File.ReadAllBytesAsync(imagePath);
    var imageContent = new ByteArrayContent(imageBytes);
    
    // 根据文件扩展名设置 Content-Type
    string ext = System.IO.Path.GetExtension(imagePath).ToLower();
    string mimeType = ext switch
    {
        ".jpg" or ".jpeg" => "image/jpeg",
        ".png"            => "image/png",
        ".webp"           => "image/webp",
        _                 => "application/octet-stream"
    };
    imageContent.Headers.ContentType = new MediaTypeHeaderValue(mimeType);

    string fileName = System.IO.Path.GetFileName(imagePath);
    formData.Add(imageContent, "image", fileName);
}

Console.WriteLine("正在发送请求...");

try
{
    HttpResponseMessage response = await httpClient.PostAsync(
        "https://maas-openapi.wanjiedata.com/api/v1/images/edits",
        formData
    );

    string responseBody = await response.Content.ReadAsStringAsync();

    Console.WriteLine($"状态码: {(int)response.StatusCode} {response.StatusCode}");
    Console.WriteLine($"响应内容:\n{responseBody}");
}
catch (HttpRequestException ex)
{
    Console.WriteLine($"请求失败: {ex.Message}");
}

响应示例

shell
{
    "created": 1777432660,
    "background": "",
    "data": [
        {
            "b64_json": $base 64编码,
            "revised_prompt": "",
            "url": ""
        }
    ],
    "output_format": "",
    "quality": "",
    "size": "",
    "usage": {
        "input_tokens": 1111,
        "input_tokens_details": {
            "image_tokens": 1105,
            "text_tokens": 6
        },
        "output_tokens": 1105,
        "total_tokens": 2216
    }
}

图片修改接口参数说明见 OpenAI API edit image

Open AI 图片分析

shell
POST /v1/responses
shell
curl --location 'https://maas-openapi.wanjiedata.com/api/v1/responses' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $API_KEY' \
--data '{
    "model": "$模型名称",
    "input": [
      {
        "role": "user",
        "content": [
          {"type": "input_text", "text": "这是什么图片?"},
          {
            "type": "input_image",
            "image_url": "图片 URL"
          }
        ]
      }
    ]
  }'
python
import requests
import json

url = "https://maas-openapi.wanjiedata.com/api/v1/responses"

# 替换为你的实际API Key
api_key = "你的API_KEY"

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {api_key}"
}

# 替换为实际的图片URL
image_url = "图片 URL"

data = {
    "model": "GPT-4o",
    "input": [
        {
            "role": "user",
            "content": [
                {
                    "type": "input_text",
                    "text": "这是什么图片?"
                },
                {
                    "type": "input_image",
                    "image_url": image_url
                }
            ]
        }
    ]
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
javascript
import axios from 'axios';

async function main() {
    try {
        const response = await axios.post(
            'https://maas-openapi.wanjiedata.com/api/v1/responses',
            {
                "model": "GPT-4o",
                "input": [
                    {
                        "role": "user",
                        "content": [
                            {"type": "input_text", "text": "这是什么图片?"},
                            {
                                "type": "input_image",
                                "image_url": "你的图片 URL"
                            }
                        ]
                    }
                ]
            },
            {
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': 'Bearer 你的 KEY'
                }
            }
        );

        console.log('识别结果:', JSON.stringify(response.data, null, 2));

    } catch (error) {
        console.error('错误:', error.message);
        if (error.response) {
            console.error('响应状态:', error.response.status);
            console.error('响应数据:', error.response.data);
        }
    }
}

main();
csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

// ===== 配置区域 =====
string apiKey = "YOUR_API_KEY";
string imageUrl = "图片 URL";
string question = "这是什么图片?";
// ====================

var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", apiKey);

var requestBody = new
{
    model = "GPT-4o",
    input = new[]
    {
        new
        {
            role = "user",
            content = new object[]
            {
                new { type = "input_text",  text = question },
                new { type = "input_image", image_url = imageUrl }
            }
        }
    }
};

string jsonBody = JsonSerializer.Serialize(requestBody);
var content = new StringContent(jsonBody, Encoding.UTF8, "application/json");

Console.WriteLine("正在发送请求...");

try
{
    HttpResponseMessage response = await httpClient.PostAsync(
        "https://maas-openapi.wanjiedata.com/api/v1/responses",
        content
    );

    string responseBody = await response.Content.ReadAsStringAsync();

    Console.WriteLine($"状态码: {(int)response.StatusCode} {response.StatusCode}");
    Console.WriteLine($"响应内容:\n{responseBody}");
}
catch (HttpRequestException ex)
{
    Console.WriteLine($"请求失败: {ex.Message}");
}

响应示例

shell
{
    "id": "resp_08fd292f202a4f970069a6a11852788197be7d3d76b63dd7f8",
    "created_at": 0,
    "error": {
        "code": "",
        "message": ""
    },
    "incomplete_details": {
        "reason": ""
    },
    "instructions": {
        "OfString": "",
        "OfInputItemList": null
    },
    "metadata": {},
    "model": "GPT-4o",
    "object": "response",
    "output": [
        {
            "id": "msg_08fd292f202a4f970069a6a11c6558819796088bc6d67d7bfd",
            "content": [
                {
                    "annotations": [],
                    "text": "这是一张充满幻想色彩的艺术插图。画面中,一个庞大的宇宙形象,占据了整个背景,看起来像是星云和星球构成的巨大面孔。这个形象将手伸向地球,给人一种神秘而强大的感觉,似乎在操控或守护着星球。这种风格常用于科幻或奇幻题材的作品中。",
                    "type": "output_text",
                    "logprobs": [],
                    "refusal": ""
                }
            ],
            "role": "assistant",
            "status": "completed",
            "type": "message",
            "queries": null,
            "results": null,
            "arguments": "",
            "call_id": "",
            "name": "",
            "action": {
                "query": "",
                "type": "",
                "sources": null,
                "url": "",
                "pattern": "",
                "button": "",
                "x": 0,
                "y": 0,
                "path": null,
                "keys": null,
                "scroll_x": 0,
                "scroll_y": 0,
                "text": "",
                "command": null,
                "env": null,
                "timeout_ms": 0,
                "user": "",
                "working_directory": "",
                "commands": null,
                "max_output_length": 0
            },
            "pending_safety_checks": null,
            "summary": null,
            "encrypted_content": "",
            "created_by": "",
            "result": "",
            "code": "",
            "container_id": "",
            "outputs": null,
            "max_output_length": 0,
            "output": {
                "OfResponseFunctionShellToolCallOutputOutputArray": null,
                "OfString": ""
            },
            "operation": {
                "diff": "",
                "path": "",
                "type": ""
            },
            "server_label": "",
            "approval_request_id": "",
            "error": "",
            "tools": null,
            "input": ""
        }
    ],
    "parallel_tool_calls": false,
    "temperature": 1,
    "tool_choice": {
        "OfToolChoiceMode": "",
        "mode": "",
        "tools": null,
        "type": "",
        "name": "",
        "server_label": ""
    },
    "tools": [],
    "top_p": 0,
    "background": false,
    "conversation": {
        "id": ""
    },
    "max_output_tokens": 0,
    "max_tool_calls": 0,
    "previous_response_id": "",
    "prompt": {
        "id": "",
        "variables": null,
        "version": ""
    },
    "prompt_cache_key": "",
    "prompt_cache_retention": "",
    "reasoning": {
        "effort": "",
        "generate_summary": "",
        "summary": ""
    },
    "safety_identifier": "",
    "service_tier": "",
    "status": "completed",
    "text": {
        "format": {
            "type": "text",
            "name": "",
            "schema": null,
            "description": "",
            "strict": false
        },
        "verbosity": "medium"
    },
    "top_logprobs": 0,
    "truncation": "disabled",
    "usage": {
        "input_tokens": 1116,
        "input_tokens_details": {
            "cached_tokens": 0
        },
        "output_tokens": 95,
        "output_tokens_details": {
            "reasoning_tokens": 0
        },
        "total_tokens": 1211
    },
    "user": ""
}
python
{'id': 'resp_04e9d735e71880180069a6a07a24c08193ae0b2f7d8d505723', 'created_at': 0, 'error': {'code': '', 'message': ''}, 'incomplete_details': {'reason': ''}, 'instructions': {'OfString': '', 'OfInputItemList': None}, 'metadata': {}, 'model': 'GPT-4o', 'object': 'response', 'output': [{'id': 'msg_04e9d735e71880180069a6a07e292881939b937b406c9640fe', 'content': [{'annotations': [], 'text': '这是一幅幻想风格的图像,可能出自科幻或奇幻主题作品。背景是宇宙,有许多星球和漂浮的陨石。画面中有一个巨大的、神秘的生物,它有着闪烁的眼睛和伸展的手掌,似乎在操控地球或类似星球。这种艺术风格常用于游戏、电影或插画中。本图片可能与一种称为“宇宙魔神”的角色有关。', 'type': 'output_text', 'logprobs': [], 'refusal': ''}], 'role': 'assistant', 'status': 'completed', 'type': 'message', 'queries': None, 'results': None, 'arguments': '', 'call_id': '', 'name': '', 'action': {'query': '', 'type': '', 'sources': None, 'url': '', 'pattern': '', 'button': '', 'x': 0, 'y': 0, 'path': None, 'keys': None, 'scroll_x': 0, 'scroll_y': 0, 'text': '', 'command': None, 'env': None, 'timeout_ms': 0, 'user': '', 'working_directory': '', 'commands': None, 'max_output_length': 0}, 'pending_safety_checks': None, 'summary': None, 'encrypted_content': '', 'created_by': '', 'result': '', 'code': '', 'container_id': '', 'outputs': None, 'max_output_length': 0, 'output': {'OfResponseFunctionShellToolCallOutputOutputArray': None, 'OfString': ''}, 'operation': {'diff': '', 'path': '', 'type': ''}, 'server_label': '', 'approval_request_id': '', 'error': '', 'tools': None, 'input': ''}], 'parallel_tool_calls': False, 'temperature': 1, 'tool_choice': {'OfToolChoiceMode': '', 'mode': '', 'tools': None, 'type': '', 'name': '', 'server_label': ''}, 'tools': [], 'top_p': 0, 'background': False, 'conversation': {'id': ''}, 'max_output_tokens': 0, 'max_tool_calls': 0, 'previous_response_id': '', 'prompt': {'id': '', 'variables': None, 'version': ''}, 'prompt_cache_key': '', 'prompt_cache_retention': '', 'reasoning': {'effort': '', 'generate_summary': '', 'summary': ''}, 'safety_identifier': '', 'service_tier': '', 'status': 'completed', 'text': {'format': {'type': 'text', 'name': '', 'schema': None, 'description': '', 'strict': False}, 'verbosity': 'medium'}, 'top_logprobs': 0, 'truncation': 'disabled', 'usage': {'input_tokens': 1116, 'input_tokens_details': {'cached_tokens': 0}, 'output_tokens': 111, 'output_tokens_details': {'reasoning_tokens': 0}, 'total_tokens': 1227}, 'user': ''}
javascript
识别结果: {
    "id": "resp_0a852221b7e442750069a6a2a0f80c8190be9d6fa2d2ca9049",
        "created_at": 0,
        "error": {
        "code": "",
            "message": ""
    },
    "incomplete_details": {
        "reason": ""
    },
    "instructions": {
        "OfString": "",
            "OfInputItemList": null
    },
    "metadata": {},
    "model": "GPT-4o",
        "object": "response",
        "output": [
        {
            "id": "msg_0a852221b7e442750069a6a2a61ea0819083da09c822bad94f",
            "content": [
                {
                    "annotations": [],
                    "text": "这是一幅充满幻想色彩的宇宙艺术插画,表现了一个超自然的生物或宇宙之神的形象。这个生物由星云、星空构成,背景中还有行星和小行星。它的双手发出光芒,似乎在操控或俯视地 球,营造出一种神秘且震撼的气氛。这通常出现在科幻或奇幻主题的游戏、电影或艺术作品中。",
                    "type": "output_text",
                    "logprobs": [],
                    "refusal": ""
                }
            ],
            "role": "assistant",
            "status": "completed",
            "type": "message",
            "queries": null,
            "results": null,
            "arguments": "",
            "call_id": "",
            "name": "",
            "action": {
                "query": "",
                "type": "",
                "sources": null,
                "url": "",
                "pattern": "",
                "button": "",
                "x": 0,
                "y": 0,
                "path": null,
                "keys": null,
                "scroll_x": 0,
                "scroll_y": 0,
                "text": "",
                "command": null,
                "env": null,
                "timeout_ms": 0,
                "user": "",
                "working_directory": "",
                "commands": null,
                "max_output_length": 0
            },
            "pending_safety_checks": null,
            "summary": null,
            "encrypted_content": "",
            "created_by": "",
            "result": "",
            "code": "",
            "container_id": "",
            "outputs": null,
            "max_output_length": 0,
            "output": {
                "OfResponseFunctionShellToolCallOutputOutputArray": null,
                "OfString": ""
            },
            "operation": {
                "diff": "",
                "path": "",
                "type": ""
            },
            "server_label": "",
            "approval_request_id": "",
            "error": "",
            "tools": null,
            "input": ""
        }
    ],
        "parallel_tool_calls": false,
        "temperature": 1,
        "tool_choice": {
        "OfToolChoiceMode": "",
            "mode": "",
            "tools": null,
            "type": "",
            "name": "",
            "server_label": ""
    },
    "tools": [],
        "top_p": 0,
        "background": false,
        "conversation": {
        "id": ""
    },
    "max_output_tokens": 0,
        "max_tool_calls": 0,
        "previous_response_id": "",
        "prompt": {
        "id": "",
            "variables": null,
            "version": ""
    },
    "prompt_cache_key": "",
        "prompt_cache_retention": "",
        "reasoning": {
        "effort": "",
            "generate_summary": "",
            "summary": ""
    },
    "safety_identifier": "",
        "service_tier": "",
        "status": "completed",
        "text": {
        "format": {
            "type": "text",
                "name": "",
                "schema": null,
                "description": "",
                "strict": false
        },
        "verbosity": "medium"
    },
    "top_logprobs": 0,
        "truncation": "disabled",
        "usage": {
        "input_tokens": 1116,
            "input_tokens_details": {
            "cached_tokens": 0
        },
        "output_tokens": 112,
            "output_tokens_details": {
            "reasoning_tokens": 0
        },
        "total_tokens": 1228
    },
    "user": ""
}
csharp
正在发送请求...
状态码: 200 OK
响应内容:
{"id":"resp_0ea9f656a9ae30470069a6aff8d7608190a27c6e718b4c029f","created_at":0,"error":{"code":"","message":""},"incomplete_details":{"reason":""},"instructions":{"OfString":"","OfInputItemList":null},"metadata":{},"model":"GPT-4o","object":"response","output":[{"id":"msg_0ea9f656a9ae30470069a6affd35308190ad45d082a6f58aaf","content":[{"annotations":[],"text":"这张图片是《英雄联盟》的角色\"巴德\"的星界游神皮肤。图中表现了一个充满神秘和宇宙元素的场景,巴德作为星界的守护者,周围环绕着星星和行星,手中散发着光芒。这幅画作展示了这位角色的宇宙主题和超自然的特质。","type":"output_text","logprobs":[],"refusal":""}],"role":"assistant","status":"completed","type":"message","queries":null,"results":null,"arguments":"","call_id":"","name":"","action":{"query":"","type":"","sources":null,"url":"","pattern":"","button":"","x":0,"y":0,"path":null,"keys":null,"scroll_x":0,"scroll_y":0,"text":"","command":null,"env":null,"timeout_ms":0,"user":"","working_directory":"","commands":null,"max_output_length":0},"pending_safety_checks":null,"summary":null,"encrypted_content":"","created_by":"","result":"","code":"","container_id":"","outputs":null,"max_output_length":0,"output":{"OfResponseFunctionShellToolCallOutputOutputArray":null,"OfString":""},"operation":{"diff":"","path":"","type":""},"server_label":"","approval_request_id":"","error":"","tools":null,"input":""}],"parallel_tool_calls":false,"temperature":1,"tool_choice":{"OfToolChoiceMode":"","mode":"","tools":null,"type":"","name":"","server_label":""},"tools":[],"top_p":0,"background":false,"conversation":{"id":""},"max_output_tokens":0,"max_tool_calls":0,"previous_response_id":"","prompt":{"id":"","variables":null,"version":""},"prompt_cache_key":"","prompt_cache_retention":"","reasoning":{"effort":"","generate_summary":"","summary":""},"safety_identifier":"","service_tier":"","status":"completed","text":{"format":{"type":"text","name":"","schema":null,"description":"","strict":false},"verbosity":"medium"},"top_logprobs":0,"truncation":"disabled","usage":{"input_tokens":1116,"input_tokens_details":{"cached_tokens":0},"output_tokens":90,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":1206},"user":""}

OpenAI 接口标准适用模型配置相关文档参考

在 Cherry Studio 中配置 OpenAI 接口标准适用模型

Deep Research Web UI 配置 OpenAI 接口标准适用模型教程