OpenAI API 兼容
请求地址
https://api.xiaomimimo.com/v1/chat/completions
请求头
接口支持以下两种认证方式,请选择其中一种添加到请求头中:
-
方式一:
api-key字段认证,格式:api-key: $MIMO_API_KEY Content-Type: application/json -
方式二:
Authorization: Bearer认证,格式:Authorization: Bearer $MIMO_API_KEY Content-Type: application/json
请求体
- messagesarray必选对话的消息列表。隐藏子属性开发者提供的指令,模型应遵循这些指令,而不受用户发送的消息影响。隐藏子属性messages.contentstring | array必选开发者消息的内容。隐藏子属性开发者消息的内容。messages.rolestring必选开发者消息的角色。
可选值:developermessages.namestring参与者的可选名称。为模型提供信息以区分相同角色的参与者。 - modelstring必选用于生成响应的模型 ID。
可选值:mimo-v2.5-pro,mimo-v2.5,mimo-v2.5-tts,mimo-v2.5-tts-voicedesign,mimo-v2.5-tts-voiceclone,mimo-v2-pro,mimo-v2-omni,mimo-v2-tts,mimo-v2-flash - audioobject音频输出参数。详情请参考 语音合成。
注意:如果要生成音频,必须添加一条
role为assistant的消息,该消息需指定用于音频合成的文本。此外,使用mimo-v2.5-tts-voicedesign模型时,role为user的消息为必填。详细用法请参考 语音合成。当前仅支持
mimo-v2.5-tts,mimo-v2.5-tts-voicedesign,mimo-v2.5-tts-voiceclone和mimo-v2-tts模型。隐藏子属性audio.formatstring默认值: wav指定输出音频格式。默认值:wav,如果设置stream: true则为pcm。传入
可选值:pcm或pcm16,均表示指定使用pcm16格式。wav,mp3,pcm,pcm16audio.voicestring预置音色的音色ID 或音频样本的 base64 编码。mimo-v2.5-tts,mimo-v2-tts:该字段为可选,且仅支持使用预置音色,默认值为mimo_defaultmimo-v2.5-tts-voiceclone:该字段为必填,且仅支持传入音频样本的 base64 编码,仅支持传入mp3和wav格式的音频样本文件mimo-v2.5-tts-voicedesign:不支持该字段
mimo-v2-tts:mimo_default,default_en,default_zhmimo-v2.5-tts:mimo_default,冰糖,茉莉,苏打,白桦,Mia,Chloe,Milo,Dean
- frequency_penaltynumber | null默认值: 0取值范围在 -2.0 到 2.0 之间的数值。如果该值为正,那么新 token 会根据其在已有文本中的出现频率受到相应的惩罚,降低模型重复相同内容的可能性。
所需范围:[-2.0, 2.0] - max_completion_tokensinteger | null对话补全中可以生成的 token 数的上限,包括可见的输出 token 数和推理 token 数。
mimo-v2-flash的默认值65536mimo-v2.5-pro,mimo-v2-pro的默认值131072mimo-v2.5,mimo-v2-omni的默认值为32768mimo-v2.5-tts,mimo-v2.5-tts-voiceclone,mimo-v2.5-tts-voicedesign,mimo-v2-tts的默认值为8192,取值范围为[0, 8192]
[0, 131072] - presence_penaltynumber | null默认值: 0取值范围在 -2.0 到 2.0 之间的数值。如果该值为正,那么新 token 会根据其是否已在已有文本中出现受到相应的惩罚,从而增加模型谈论新主题的可能性。
所需范围:[-2.0, 2.0] - response_formatobject一个指定模型必须输出的格式的对象。
mimo-v2.5-tts,mimo-v2.5-tts-voicedesign,mimo-v2.5-tts-voiceclone和mimo-v2-tts模型不支持。隐藏子属性默认响应格式。用于生成文本响应。隐藏子属性response_format.typestring必选所定义的响应格式类型。仅为text。 - stopstring | array | null默认值: null最多 4 个序列,当 API 生成到这些序列时会停止继续生成 token。返回的文本中不会包含这些停止序列。
mimo-v2.5-tts,mimo-v2.5-tts-voicedesign,mimo-v2.5-tts-voiceclone和mimo-v2-tts模型不支持。 - streamboolean | null默认值: false如果设置为 true,模型的响应数据会在生成过程中通过SSE(server-sent events)的形式流式传输到客户端。
- thinkingobject这个参数用于控制模型是否启用思维链。
注意:在思考模式下的多轮工具调用过程中,模型会在返回
tool_calls字段的同时返回reasoning_content字段。若要继续对话,建议在后续每次请求的messages数组中保留所有历史reasoning_content,以获得最佳表现。mimo-v2.5-tts,mimo-v2.5-tts-voicedesign,mimo-v2.5-tts-voiceclone和mimo-v2-tts模型不支持。隐藏子属性thinking.typestring必选是否启用思维链mimo-v2-flash默认值为disabledmimo-v2.5-pro,mimo-v2.5,mimo-v2-pro,mimo-v2-omni默认值为enabled
enabled,disabled - temperaturenumber要使用的采样温度,介于 0 和 1.5 之间。较高的值(如 0.8)会使输出更加随机,而较低的值(如 0.2)会使其更加集中和确定性。我们通常建议更改此值或
top_p,但不要同时更改。mimo-v2-flash默认值为0.3mimo-v2.5-pro,mimo-v2.5,mimo-v2-pro,mimo-v2-omni默认值为1.0mimo-v2.5-tts,mimo-v2.5-tts-voiceclone,mimo-v2.5-tts-voicedesign,mimo-v2-tts默认值为0.6
[0, 1.5] - tool_choicestring控制模型如何选择工具。
注意:当
tool_choice传入非auto值时,后端会默认移除该字段,模型响应行为仍等同于auto模式(该逻辑保留调整的可能性)。
可选值:mimo-v2.5-tts,mimo-v2.5-tts-voicedesign,mimo-v2.5-tts-voiceclone和mimo-v2-tts模型不支持。auto - toolsarray模型可能调用的工具列表。目前仅支持函数作为工具。
注意:在思考模式下的多轮工具调用过程中,模型会在返回
tool_calls字段的同时返回reasoning_content字段。若要继续对话,建议在后续每次请求的messages数组中保留所有历史reasoning_content,以获得最佳表现。mimo-v2.5-tts,mimo-v2.5-tts-voicedesign,mimo-v2.5-tts-voiceclone和mimo-v2-tts模型不支持。隐藏子属性可用于生成响应的函数工具。隐藏子属性tools.functionobject必选隐藏子属性tools.function.namestring必选工具函数的名称。必须由a-z、A-Z、0-9组成,或包含下划线(_)和连字符(-),最大长度为64。
所需字符串长度:1 - 64tools.function.descriptionstring函数功能的描述,供模型判断何时以及如何调用该函数。tools.function.parametersobject函数接受的参数,以 JSON 模式对象的形式描述。
若省略parameters,则表示该函数的参数列表为空。tools.function.strictboolean默认值: false生成函数调用时是否启用严格的模式遵循。若设为 true,模型将严格遵循parameters字段中定义的确切模式。当strict为true时,仅支持 JSON 模式的一个子集。tools.typestring必选工具类型。目前仅支持function。 - top_pnumber默认值: 0.95核采样的概率阈值,用于控制模型生成文本的多样性。
top_p值越高,生成的文本多样性越强;top_p值越低,生成的文本确定性越高。
由于temperature和top_p均用于控制生成文本的多样性,建议仅设置其中一个参数。
所需范围:[0.01, 1.0]
Chat 响应对象(非流式输出)
- choicesarray包含生成的回复选项列表。隐藏子属性choices.finish_reasonstring模型停止生成 token 的原因。如果模型到达自然停止点或提供的停止序列,则为
stop;如果达到请求中指定的最大 token 数,则为length;如果模型调用了工具,则为tool_calls。如果内容因触发过滤策略而被拦截,则为content_filter;如果模型检测到了复读,则为repetition_truncation。choices.indexinteger选项列表中对应选项的索引。choices.messageobject模型生成的对话补全消息。隐藏子属性choices.message.contentstring消息的内容。choices.message.reasoning_contentstring助手消息中最终答案之前的推理内容。choices.message.rolestring消息作者的角色。choices.message.tool_callsarray函数调用启动后,模型会返回待调用的工具以及该调用所需的参数。此参数可包含一个或多个工具响应对象。隐藏子属性模型创建的对函数工具的调用。隐藏子属性choices.message.tool_calls.functionobject模型所调用的函数。隐藏子属性choices.message.tool_calls.function.argumentsstring模型生成的用于调用函数的参数,格式为 JSON。请注意,模型生成的内容并非并非总能保证是有效的 JSON,且可能会虚构出函数模式中未定义的参数。在调用函数之前,请在代码中对这些参数进行验证。choices.message.tool_calls.function.namestring要调用的函数的名称。choices.message.tool_calls.idstring工具调用的 ID。choices.message.tool_calls.typestring工具的类型。目前仅支持function。choices.message.annotationsarray联网搜索后,模型会返回全部引用网址的注释。隐藏子属性模型创建的对联网搜索的调用。隐藏子属性choices.message.annotations.logo_urlstringlogo网址。choices.message.annotations.publish_timestring发布时间。choices.message.annotations.site_namestring网站名称。choices.message.annotations.summarystring总结。choices.message.annotations.titlestring标题。choices.message.annotations.typestring类型。choices.message.annotations.urlstring网址。choices.message.error_messagestring联网搜索的错误信息。choices.message.audioobject如果请求输出音频,该对象将包含有关模型音频响应的数据。隐藏子属性choices.message.audio.idstring此音频响应的唯一标识符。choices.message.audio.datastring模型生成的 Base64 编码音频,格式为请求中指定的格式。choices.message.audio.expires_atnumber | null此音频响应过期的 Unix 时间戳(以秒为单位)。当前仅为null。choices.message.audio.transcriptstring | null模型生成的音频的文字记录。当前仅为null。 - createdinteger对话补全对象创建时的 Unix 时间戳(以秒为单位)。
- idstring响应的唯一标识符。
- modelstring用于生成结果的模型。
- objectstring对象类型,仅为
chat.completion。 - usageobject | null该对话补全请求的用量信息。隐藏子属性usage.completion_tokensinteger模型输出内容花费的 token。usage.prompt_tokensinteger提示词使用的 token 数量。usage.total_tokensinteger请求中使用的 token 总数(提示词 + 补全结果)。usage.completion_tokens_detailsobject补全中使用的 token 数量明细。隐藏子属性usage.completion_tokens_details.reasoning_tokensinteger模型为推理生成的 token 数量。usage.prompt_tokens_detailsobject提示中使用的 token 数量明细。隐藏子属性usage.prompt_tokens_details.cached_tokensinteger缓存中提供的 token 数量。usage.prompt_tokens_details.audio_tokensinteger提示中存在的音频输入 token 数量。usage.prompt_tokens_details.image_tokensinteger提示中存在的图像输入 token 数量。usage.prompt_tokens_details.video_tokensinteger提示中存在的视频输入 token 数量。usage.web_search_usageobject联网搜索 api 的调用量明细。隐藏子属性usage.web_search_usage.tool_usageinteger联网搜索 api 的调用次数。usage.web_search_usage.page_usageinteger联网搜索 api 返回的网页数。
Chat 响应chunk对象(流式输出)
- choicesarray包含生成的回复选项列表。隐藏子属性choices.deltaobject流式模型响应生成的对话补全增量。隐藏子属性choices.delta.contentstring数据块消息的内容。choices.delta.reasoning_contentstring助手消息中最终答案之前的推理内容。choices.delta.rolestring消息作者的角色。choices.delta.tool_callsarray函数调用启动后,模型会返回待调用的工具以及该调用所需的参数。此参数可包含一个或多个工具响应对象。隐藏子属性choices.delta.tool_calls.indexinteger在
tool_calls列表中被调用工具的索引,从 0 开始。choices.delta.tool_calls.functionobject调用的函数。隐藏子属性choices.delta.tool_calls.function.argumentsstring模型生成的用于调用函数的参数,格式为 JSON。请注意,模型生成的内容并非并非总能保证是有效的 JSON,且可能会虚构出函数模式中未定义的参数。在调用函数之前,请在代码中对这些参数进行验证。choices.delta.tool_calls.function.namestring要调用的函数的名称。choices.delta.tool_calls.idstring工具调用的 ID。choices.delta.tool_calls.typestring工具的类型。目前仅支持function。choices.delta.annotationsarray联网搜索后,模型会返回全部引用网址的注释。隐藏子属性模型创建的对联网搜索的调用。隐藏子属性choices.delta.annotations.logo_urlstringlogo网址。choices.delta.annotations.publish_timestring发布时间。choices.delta.annotations.site_namestring网站名称。choices.delta.annotations.summarystring总结。choices.delta.annotations.titlestring标题。choices.delta.annotations.typestring类型。choices.delta.annotations.urlstring网址。choices.delta.error_messagestring联网搜索链路的错误信息。choices.delta.audioobject | null如果请求输出音频,该对象将包含有关模型音频响应的数据。隐藏子属性choices.delta.audio.idstring此音频响应的唯一标识符。choices.delta.audio.datastring模型生成的 Base64 编码音频,格式为请求中指定的格式。choices.delta.audio.expires_atnumber | null此音频响应过期的 Unix 时间戳(以秒为单位)。当前仅为null。choices.delta.audio.transcriptstring | null模型生成的音频的文字记录。当前仅为null。choices.finish_reasonstring | null模型停止生成 token 的原因。如果模型到达自然停止点或提供的停止序列,则为stop;如果达到请求中指定的最大 token 数,则为length;如果模型调用了工具,则为tool_calls。如果内容因触发过滤策略而被拦截,则为content_filter;如果模型检测到了复读,则为repetition_truncation。choices.indexinteger选项列表中对应选项的索引。 - createdinteger对话补全对象创建时的 Unix 时间戳(以秒为单位)。每个数据块均使用相同的时间戳。
- idstring对话补全对象的唯一标识符。每个数据块均使用相同的 ID。
- modelstring用于生成结果的模型。
- objectstring对象类型,仅为
chat.completion.chunk。 - usageobject | null该对话补全请求的用量信息。隐藏子属性usage.completion_tokensinteger模型输出内容花费的 token。usage.prompt_tokensinteger提示词使用的 token 数量。usage.total_tokensinteger请求中使用的 token 总数(提示词 + 补全结果)。usage.completion_tokens_detailsobject补全中使用的 token 数量明细。隐藏子属性usage.completion_tokens_details.reasoning_tokensinteger模型为推理生成的 token 数量。usage.prompt_tokens_detailsobject提示中使用的 token 数量明细。隐藏子属性usage.prompt_tokens_details.cached_tokensinteger缓存中提供的 token 数量。usage.prompt_tokens_details.audio_tokensinteger提示中存在的音频输入 token 数量。usage.prompt_tokens_details.image_tokensinteger提示中存在的图像输入 token 数量。usage.prompt_tokens_details.video_tokensinteger提示中存在的视频输入 token 数量。usage.web_search_usageobject联网搜索 api 的调用量明细。隐藏子属性usage.web_search_usage.tool_usageinteger联网搜索 api 的调用次数。usage.web_search_usage.page_usageinteger联网搜索 api 返回的网页数。
curl --location --request POST 'https://api.xiaomimimo.com/v1/chat/completions' \ --header "api-key: $MIMO_API_KEY" \ --header 'Content-Type: application/json' \ --data-raw '{ "model": "mimo-v2.5-tts", "messages": [ { "role": "user", "content": "Bright, bouncy, slightly sing-song tone — like you are bursting with good news you can barely hold in. Fast pace, rising pitch at the end." }, { "role": "assistant", "content": "Hey boss — guess what, guess what? I just got the results back and I actually passed! Not just passed, I got a distinction! I know, I know — you told me I was cutting it close, but hey, here we are. Drinks are on me tonight, okay?" } ], "audio": { "format": "wav", "voice": "mimo_default" } }'
响应
{ "id": "6ebed286b58546f6b87fa7fa9d0e806b", "choices": [ { "finish_reason": "stop", "index": 0, "message": { "content": "", "role": "assistant", "audio": { "id": "979a91904f9a4143928d9e1f54837b4f", "data": "base64Data", "expires_at": null, "transcript": null }, "tool_calls": null } } ], "created": 1776954802, "model": "mimo-v2.5-tts", "object": "chat.completion", "usage": { "completion_tokens": 97, "prompt_tokens": 213, "total_tokens": 310, "completion_tokens_details": { "reasoning_tokens": 0 }, "prompt_tokens_details": { "cached_tokens": 109 } } }