[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"docs-nav-en":3,"docs-en-models\u002Fchat\u002Fopenai":144,"$f5G-W5pbZXaBL-tapeTlB9kzAJ5U7Brc5g5gu3AoucWU":833},[4,52,69,119,136,140],{"title":5,"path":6,"stem":7,"children":8,"page":-1},"Getting Started","\u002Fgetting-started","1.getting-started",[9,12,30,44,48],{"title":10,"path":6,"stem":11},"About SilvaMux","1.getting-started\u002Findex",{"title":13,"path":14,"stem":15,"children":16,"page":-1},"Your First SilvaMux API Call","\u002Fgetting-started\u002Fquick-start","1.getting-started\u002F1.quick-start\u002Findex",[17,18,22,26],{"title":13,"path":14,"stem":15},{"title":19,"path":20,"stem":21},"Projects & Account Setup","\u002Fgetting-started\u002Fquick-start\u002Fproject-and-account","1.getting-started\u002F1.quick-start\u002F2.project-and-account",{"title":23,"path":24,"stem":25},"Get an API Key","\u002Fgetting-started\u002Fquick-start\u002Fapi-key","1.getting-started\u002F1.quick-start\u002F3.api-key",{"title":27,"path":28,"stem":29},"First Request","\u002Fgetting-started\u002Fquick-start\u002Ffirst-request","1.getting-started\u002F1.quick-start\u002F4.first-request",{"title":31,"path":32,"stem":33,"children":34,"page":43},"Models & Experience","\u002Fgetting-started\u002Fmodels-and-experience","1.getting-started\u002F2.models-and-experience",[35,39],{"title":36,"path":37,"stem":38},"Model Selection","\u002Fgetting-started\u002Fmodels-and-experience\u002Fmodel-selection","1.getting-started\u002F2.models-and-experience\u002F1.model-selection",{"title":40,"path":41,"stem":42},"Playground","\u002Fgetting-started\u002Fmodels-and-experience\u002Fplayground","1.getting-started\u002F2.models-and-experience\u002F2.playground",false,{"title":45,"path":46,"stem":47},"Rate Limits","\u002Fgetting-started\u002Frate-limits","1.getting-started\u002F3.rate-limits",{"title":49,"path":50,"stem":51},"FAQ","\u002Fgetting-started\u002Ffaq","1.getting-started\u002F4.faq",{"title":53,"path":54,"stem":55,"children":56,"page":43},"Billing","\u002Fbilling","2.billing",[57,61,65],{"title":58,"path":59,"stem":60},"Billing Overview","\u002Fbilling\u002Foverview","2.billing\u002F1.overview",{"title":62,"path":63,"stem":64},"Online Top-up","\u002Fbilling\u002Frecharge","2.billing\u002F2.recharge",{"title":66,"path":67,"stem":68},"Bills, Usage & Exports","\u002Fbilling\u002Fusage-export","2.billing\u002F3.usage-export",{"title":70,"path":71,"stem":72,"children":73,"page":43},"Model APIs","\u002Fmodels","4.models",[74,107],{"title":75,"path":76,"stem":77,"children":78,"page":43},"Text Generation","\u002Fmodels\u002Fchat","4.models\u002F1.chat",[79,83,87,91,95,99,103],{"title":80,"path":81,"stem":82},"Overview","\u002Fmodels\u002Fchat\u002Foverview","4.models\u002F1.chat\u002F1.overview",{"title":84,"path":85,"stem":86},"OpenAI Compatible API","\u002Fmodels\u002Fchat\u002Fopenai","4.models\u002F1.chat\u002F2.openai",{"title":88,"path":89,"stem":90},"Anthropic Compatible","\u002Fmodels\u002Fchat\u002Fanthropic","4.models\u002F1.chat\u002F3.anthropic",{"title":92,"path":93,"stem":94},"Volcengine Compatible","\u002Fmodels\u002Fchat\u002Fvolcengine","4.models\u002F1.chat\u002F4.volcengine",{"title":96,"path":97,"stem":98},"Zhipu Compatible","\u002Fmodels\u002Fchat\u002Fzhipu","4.models\u002F1.chat\u002F5.zhipu",{"title":100,"path":101,"stem":102},"SilvaMux Unified Entry","\u002Fmodels\u002Fchat\u002Funified","4.models\u002F1.chat\u002F6.unified",{"title":104,"path":105,"stem":106},"Multimodal Input","\u002Fmodels\u002Fchat\u002Fmultimodal","4.models\u002F1.chat\u002F7.multimodal",{"title":108,"path":109,"stem":110,"children":111,"page":43},"Image Generation","\u002Fmodels\u002Fimages","4.models\u002F2.images",[112,115],{"title":80,"path":113,"stem":114},"\u002Fmodels\u002Fimages\u002Foverview","4.models\u002F2.images\u002F1.overview",{"title":116,"path":117,"stem":118},"Image Generation API","\u002Fmodels\u002Fimages\u002Fgeneration","4.models\u002F2.images\u002F2.generation",{"title":120,"path":121,"stem":122,"children":123,"page":43},"Usage & Balance","\u002Fusage-and-balance","5.usage-and-balance",[124,128,132],{"title":125,"path":126,"stem":127},"Query Balance","\u002Fusage-and-balance\u002Fbalance","5.usage-and-balance\u002F1.balance",{"title":129,"path":130,"stem":131},"Query Usage","\u002Fusage-and-balance\u002Fusage","5.usage-and-balance\u002F2.usage",{"title":133,"path":134,"stem":135},"Query Request Usage","\u002Fusage-and-balance\u002Frequest-usage","5.usage-and-balance\u002F3.request-usage",{"title":137,"path":138,"stem":139},"Error Codes","\u002Ferrors","6.errors",{"title":141,"path":142,"stem":143},"Documentation","\u002F","index",{"id":145,"title":84,"body":146,"description":826,"extension":827,"meta":828,"navigation":309,"path":85,"rawbody":829,"requiredFlags":830,"seo":831,"stem":86,"__hash__":832},"docs_en\u002F4.models\u002F1.chat\u002F2.openai.md",{"type":147,"value":148,"toc":823},"minimark",[149,153,157,162,167,680,683,811,819],[150,151,84],"h1",{"id":152},"openai-compatible-api",[154,155,156],"p",{},"Accepts the OpenAI Chat Completions request format and preserves the matching response, SSE, and error structures. Recommended for projects using the OpenAI SDK and for most new projects — existing OpenAI SDK code migrates by changing only the base URL and API key.",[158,159],"api-endpoint",{"method":160,"path":161},"POST","\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions",[163,164,166],"h2",{"id":165},"examples","Examples",[168,169,170,280,384,475],"code-tabs",{},[171,172,174],"code-tab",{"label":173},"cURL",[175,176,181],"pre",{"className":177,"code":178,"language":179,"meta":180,"style":180},"language-bash shiki shiki-themes github-light github-dark","curl https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions \\\n  -H \"Authorization: Bearer $SILVAMUX_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"model\": \"minimax-m2.5\",\n    \"messages\": [\n      {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n      {\"role\": \"user\", \"content\": \"Hello\"}\n    ],\n    \"stream\": false\n  }'\n","bash","",[182,183,184,201,219,229,238,244,250,256,262,268,274],"code",{"__ignoreMap":180},[185,186,189,193,197],"span",{"class":187,"line":188},"line",1,[185,190,192],{"class":191},"sScJk","curl",[185,194,196],{"class":195},"sZZnC"," https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions",[185,198,200],{"class":199},"sj4cs"," \\\n",[185,202,204,207,210,214,217],{"class":187,"line":203},2,[185,205,206],{"class":199},"  -H",[185,208,209],{"class":195}," \"Authorization: Bearer ",[185,211,213],{"class":212},"sVt8B","$SILVAMUX_API_KEY",[185,215,216],{"class":195},"\"",[185,218,200],{"class":199},[185,220,222,224,227],{"class":187,"line":221},3,[185,223,206],{"class":199},[185,225,226],{"class":195}," \"Content-Type: application\u002Fjson\"",[185,228,200],{"class":199},[185,230,232,235],{"class":187,"line":231},4,[185,233,234],{"class":199},"  -d",[185,236,237],{"class":195}," '{\n",[185,239,241],{"class":187,"line":240},5,[185,242,243],{"class":195},"    \"model\": \"minimax-m2.5\",\n",[185,245,247],{"class":187,"line":246},6,[185,248,249],{"class":195},"    \"messages\": [\n",[185,251,253],{"class":187,"line":252},7,[185,254,255],{"class":195},"      {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n",[185,257,259],{"class":187,"line":258},8,[185,260,261],{"class":195},"      {\"role\": \"user\", \"content\": \"Hello\"}\n",[185,263,265],{"class":187,"line":264},9,[185,266,267],{"class":195},"    ],\n",[185,269,271],{"class":187,"line":270},10,[185,272,273],{"class":195},"    \"stream\": false\n",[185,275,277],{"class":187,"line":276},11,[185,278,279],{"class":195},"  }'\n",[171,281,283],{"label":282},"Python",[175,284,288],{"className":285,"code":286,"language":287,"meta":180,"style":180},"language-python shiki shiki-themes github-light github-dark","# pip install openai\nimport os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    api_key=os.environ[\"SILVAMUX_API_KEY\"],\n    base_url=\"https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\",\n)\n\nresponse = client.chat.completions.create(\n    model=\"minimax-m2.5\",\n    messages=[\n        {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n        {\"role\": \"user\", \"content\": \"Hello\"},\n    ],\n)\n\nprint(response.choices[0].message.content)\n","python",[182,289,290,295,300,305,311,316,321,326,331,335,340,345,351,357,363,368,373,378],{"__ignoreMap":180},[185,291,292],{"class":187,"line":188},[185,293,294],{},"# pip install openai\n",[185,296,297],{"class":187,"line":203},[185,298,299],{},"import os\n",[185,301,302],{"class":187,"line":221},[185,303,304],{},"from openai import OpenAI\n",[185,306,307],{"class":187,"line":231},[185,308,310],{"emptyLinePlaceholder":309},true,"\n",[185,312,313],{"class":187,"line":240},[185,314,315],{},"client = OpenAI(\n",[185,317,318],{"class":187,"line":246},[185,319,320],{},"    api_key=os.environ[\"SILVAMUX_API_KEY\"],\n",[185,322,323],{"class":187,"line":252},[185,324,325],{},"    base_url=\"https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\",\n",[185,327,328],{"class":187,"line":258},[185,329,330],{},")\n",[185,332,333],{"class":187,"line":264},[185,334,310],{"emptyLinePlaceholder":309},[185,336,337],{"class":187,"line":270},[185,338,339],{},"response = client.chat.completions.create(\n",[185,341,342],{"class":187,"line":276},[185,343,344],{},"    model=\"minimax-m2.5\",\n",[185,346,348],{"class":187,"line":347},12,[185,349,350],{},"    messages=[\n",[185,352,354],{"class":187,"line":353},13,[185,355,356],{},"        {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n",[185,358,360],{"class":187,"line":359},14,[185,361,362],{},"        {\"role\": \"user\", \"content\": \"Hello\"},\n",[185,364,366],{"class":187,"line":365},15,[185,367,267],{},[185,369,371],{"class":187,"line":370},16,[185,372,330],{},[185,374,376],{"class":187,"line":375},17,[185,377,310],{"emptyLinePlaceholder":309},[185,379,381],{"class":187,"line":380},18,[185,382,383],{},"print(response.choices[0].message.content)\n",[171,385,387],{"label":386},"JavaScript",[175,388,392],{"className":389,"code":390,"language":391,"meta":180,"style":180},"language-javascript shiki shiki-themes github-light github-dark","\u002F\u002F npm install openai\nimport OpenAI from \"openai\";\n\nconst client = new OpenAI({\n  apiKey: process.env.SILVAMUX_API_KEY,\n  baseURL: \"https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\",\n});\n\nconst response = await client.chat.completions.create({\n  model: \"minimax-m2.5\",\n  messages: [\n    { role: \"system\", content: \"You are a helpful assistant\" },\n    { role: \"user\", content: \"Hello\" },\n  ],\n});\n\nconsole.log(response.choices[0].message.content);\n","javascript",[182,393,394,399,404,408,413,418,423,428,432,437,442,447,452,457,462,466,470],{"__ignoreMap":180},[185,395,396],{"class":187,"line":188},[185,397,398],{},"\u002F\u002F npm install openai\n",[185,400,401],{"class":187,"line":203},[185,402,403],{},"import OpenAI from \"openai\";\n",[185,405,406],{"class":187,"line":221},[185,407,310],{"emptyLinePlaceholder":309},[185,409,410],{"class":187,"line":231},[185,411,412],{},"const client = new OpenAI({\n",[185,414,415],{"class":187,"line":240},[185,416,417],{},"  apiKey: process.env.SILVAMUX_API_KEY,\n",[185,419,420],{"class":187,"line":246},[185,421,422],{},"  baseURL: \"https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\",\n",[185,424,425],{"class":187,"line":252},[185,426,427],{},"});\n",[185,429,430],{"class":187,"line":258},[185,431,310],{"emptyLinePlaceholder":309},[185,433,434],{"class":187,"line":264},[185,435,436],{},"const response = await client.chat.completions.create({\n",[185,438,439],{"class":187,"line":270},[185,440,441],{},"  model: \"minimax-m2.5\",\n",[185,443,444],{"class":187,"line":276},[185,445,446],{},"  messages: [\n",[185,448,449],{"class":187,"line":347},[185,450,451],{},"    { role: \"system\", content: \"You are a helpful assistant\" },\n",[185,453,454],{"class":187,"line":353},[185,455,456],{},"    { role: \"user\", content: \"Hello\" },\n",[185,458,459],{"class":187,"line":359},[185,460,461],{},"  ],\n",[185,463,464],{"class":187,"line":365},[185,465,427],{},[185,467,468],{"class":187,"line":370},[185,469,310],{"emptyLinePlaceholder":309},[185,471,472],{"class":187,"line":375},[185,473,474],{},"console.log(response.choices[0].message.content);\n",[171,476,478],{"label":477},"Go",[175,479,483],{"className":480,"code":481,"language":482,"meta":180,"style":180},"language-go shiki shiki-themes github-light github-dark","\u002F\u002F Standard library only\npackage main\n\nimport (\n    \"bytes\"\n    \"fmt\"\n    \"io\"\n    \"net\u002Fhttp\"\n    \"os\"\n)\n\nfunc main() {\n    payload := []byte(`{\n        \"model\": \"minimax-m2.5\",\n        \"messages\": [\n            {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n            {\"role\": \"user\", \"content\": \"Hello\"}\n        ],\n        \"stream\": false\n    }`)\n\n    req, err := http.NewRequest(\"POST\", \"https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions\", bytes.NewReader(payload))\n    if err != nil {\n        panic(err)\n    }\n    req.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"SILVAMUX_API_KEY\"))\n    req.Header.Set(\"Content-Type\", \"application\u002Fjson\")\n\n    resp, err := http.DefaultClient.Do(req)\n    if err != nil {\n        panic(err)\n    }\n    defer resp.Body.Close()\n\n    body, _ := io.ReadAll(resp.Body)\n    fmt.Println(string(body))\n}\n","go",[182,484,485,490,495,499,504,509,514,519,524,529,533,537,542,547,552,557,562,567,572,578,584,589,595,601,607,613,619,625,630,636,641,646,651,657,662,668,674],{"__ignoreMap":180},[185,486,487],{"class":187,"line":188},[185,488,489],{},"\u002F\u002F Standard library only\n",[185,491,492],{"class":187,"line":203},[185,493,494],{},"package main\n",[185,496,497],{"class":187,"line":221},[185,498,310],{"emptyLinePlaceholder":309},[185,500,501],{"class":187,"line":231},[185,502,503],{},"import (\n",[185,505,506],{"class":187,"line":240},[185,507,508],{},"    \"bytes\"\n",[185,510,511],{"class":187,"line":246},[185,512,513],{},"    \"fmt\"\n",[185,515,516],{"class":187,"line":252},[185,517,518],{},"    \"io\"\n",[185,520,521],{"class":187,"line":258},[185,522,523],{},"    \"net\u002Fhttp\"\n",[185,525,526],{"class":187,"line":264},[185,527,528],{},"    \"os\"\n",[185,530,531],{"class":187,"line":270},[185,532,330],{},[185,534,535],{"class":187,"line":276},[185,536,310],{"emptyLinePlaceholder":309},[185,538,539],{"class":187,"line":347},[185,540,541],{},"func main() {\n",[185,543,544],{"class":187,"line":353},[185,545,546],{},"    payload := []byte(`{\n",[185,548,549],{"class":187,"line":359},[185,550,551],{},"        \"model\": \"minimax-m2.5\",\n",[185,553,554],{"class":187,"line":365},[185,555,556],{},"        \"messages\": [\n",[185,558,559],{"class":187,"line":370},[185,560,561],{},"            {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n",[185,563,564],{"class":187,"line":375},[185,565,566],{},"            {\"role\": \"user\", \"content\": \"Hello\"}\n",[185,568,569],{"class":187,"line":380},[185,570,571],{},"        ],\n",[185,573,575],{"class":187,"line":574},19,[185,576,577],{},"        \"stream\": false\n",[185,579,581],{"class":187,"line":580},20,[185,582,583],{},"    }`)\n",[185,585,587],{"class":187,"line":586},21,[185,588,310],{"emptyLinePlaceholder":309},[185,590,592],{"class":187,"line":591},22,[185,593,594],{},"    req, err := http.NewRequest(\"POST\", \"https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions\", bytes.NewReader(payload))\n",[185,596,598],{"class":187,"line":597},23,[185,599,600],{},"    if err != nil {\n",[185,602,604],{"class":187,"line":603},24,[185,605,606],{},"        panic(err)\n",[185,608,610],{"class":187,"line":609},25,[185,611,612],{},"    }\n",[185,614,616],{"class":187,"line":615},26,[185,617,618],{},"    req.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"SILVAMUX_API_KEY\"))\n",[185,620,622],{"class":187,"line":621},27,[185,623,624],{},"    req.Header.Set(\"Content-Type\", \"application\u002Fjson\")\n",[185,626,628],{"class":187,"line":627},28,[185,629,310],{"emptyLinePlaceholder":309},[185,631,633],{"class":187,"line":632},29,[185,634,635],{},"    resp, err := http.DefaultClient.Do(req)\n",[185,637,639],{"class":187,"line":638},30,[185,640,600],{},[185,642,644],{"class":187,"line":643},31,[185,645,606],{},[185,647,649],{"class":187,"line":648},32,[185,650,612],{},[185,652,654],{"class":187,"line":653},33,[185,655,656],{},"    defer resp.Body.Close()\n",[185,658,660],{"class":187,"line":659},34,[185,661,310],{"emptyLinePlaceholder":309},[185,663,665],{"class":187,"line":664},35,[185,666,667],{},"    body, _ := io.ReadAll(resp.Body)\n",[185,669,671],{"class":187,"line":670},36,[185,672,673],{},"    fmt.Println(string(body))\n",[185,675,677],{"class":187,"line":676},37,[185,678,679],{},"}\n",[154,681,682],{},"Response (OpenAI format):",[175,684,688],{"className":685,"code":686,"language":687,"meta":180,"style":180},"language-json shiki shiki-themes github-light github-dark","{\n  \"id\": \"chatcmpl-xxxx\",\n  \"choices\": [\n    {\n      \"message\": {\"role\": \"assistant\", \"content\": \"Hello! How can I help you today?\"},\n      \"finish_reason\": \"stop\"\n    }\n  ],\n  \"usage\": {\"prompt_tokens\": 20, \"completion_tokens\": 15, \"total_tokens\": 35}\n}\n","json",[182,689,690,695,709,717,722,752,762,766,770,807],{"__ignoreMap":180},[185,691,692],{"class":187,"line":188},[185,693,694],{"class":212},"{\n",[185,696,697,700,703,706],{"class":187,"line":203},[185,698,699],{"class":199},"  \"id\"",[185,701,702],{"class":212},": ",[185,704,705],{"class":195},"\"chatcmpl-xxxx\"",[185,707,708],{"class":212},",\n",[185,710,711,714],{"class":187,"line":221},[185,712,713],{"class":199},"  \"choices\"",[185,715,716],{"class":212},": [\n",[185,718,719],{"class":187,"line":231},[185,720,721],{"class":212},"    {\n",[185,723,724,727,730,733,735,738,741,744,746,749],{"class":187,"line":240},[185,725,726],{"class":199},"      \"message\"",[185,728,729],{"class":212},": {",[185,731,732],{"class":199},"\"role\"",[185,734,702],{"class":212},[185,736,737],{"class":195},"\"assistant\"",[185,739,740],{"class":212},", ",[185,742,743],{"class":199},"\"content\"",[185,745,702],{"class":212},[185,747,748],{"class":195},"\"Hello! How can I help you today?\"",[185,750,751],{"class":212},"},\n",[185,753,754,757,759],{"class":187,"line":246},[185,755,756],{"class":199},"      \"finish_reason\"",[185,758,702],{"class":212},[185,760,761],{"class":195},"\"stop\"\n",[185,763,764],{"class":187,"line":252},[185,765,612],{"class":212},[185,767,768],{"class":187,"line":258},[185,769,461],{"class":212},[185,771,772,775,777,780,782,785,787,790,792,795,797,800,802,805],{"class":187,"line":264},[185,773,774],{"class":199},"  \"usage\"",[185,776,729],{"class":212},[185,778,779],{"class":199},"\"prompt_tokens\"",[185,781,702],{"class":212},[185,783,784],{"class":199},"20",[185,786,740],{"class":212},[185,788,789],{"class":199},"\"completion_tokens\"",[185,791,702],{"class":212},[185,793,794],{"class":199},"15",[185,796,740],{"class":212},[185,798,799],{"class":199},"\"total_tokens\"",[185,801,702],{"class":212},[185,803,804],{"class":199},"35",[185,806,679],{"class":212},[185,808,809],{"class":187,"line":270},[185,810,679],{"class":212},[154,812,813,814,818],{},"The compatible entry passes through extra fields of the corresponding protocol. See ",[815,816,80],"a",{"href":817},"\u002Fen\u002Fdocs\u002Fmodels\u002Fchat\u002Foverview"," for streaming and multimodal input.",[820,821,822],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":180,"searchDepth":203,"depth":203,"links":824},[825],{"id":165,"depth":203,"text":166},"OpenAI Chat Completions compatible entry — recommended for OpenAI SDKs and most new projects.","md",{},"---\ntitle: OpenAI Compatible API\ndescription: OpenAI Chat Completions compatible entry — recommended for OpenAI SDKs and most new projects.\n---\n\n# OpenAI Compatible API\n\nAccepts the OpenAI Chat Completions request format and preserves the matching response, SSE, and error structures. Recommended for projects using the OpenAI SDK and for most new projects — existing OpenAI SDK code migrates by changing only the base URL and API key.\n\n::api-endpoint{path=\"\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions\" method=\"POST\"}\n::\n\n## Examples\n\n::code-tabs\n:::code-tab{label=\"cURL\"}\n```bash\ncurl https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions \\\n  -H \"Authorization: Bearer $SILVAMUX_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"model\": \"minimax-m2.5\",\n    \"messages\": [\n      {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n      {\"role\": \"user\", \"content\": \"Hello\"}\n    ],\n    \"stream\": false\n  }'\n```\n:::\n:::code-tab{label=\"Python\"}\n```python\n# pip install openai\nimport os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    api_key=os.environ[\"SILVAMUX_API_KEY\"],\n    base_url=\"https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\",\n)\n\nresponse = client.chat.completions.create(\n    model=\"minimax-m2.5\",\n    messages=[\n        {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n        {\"role\": \"user\", \"content\": \"Hello\"},\n    ],\n)\n\nprint(response.choices[0].message.content)\n```\n:::\n:::code-tab{label=\"JavaScript\"}\n```javascript\n\u002F\u002F npm install openai\nimport OpenAI from \"openai\";\n\nconst client = new OpenAI({\n  apiKey: process.env.SILVAMUX_API_KEY,\n  baseURL: \"https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\",\n});\n\nconst response = await client.chat.completions.create({\n  model: \"minimax-m2.5\",\n  messages: [\n    { role: \"system\", content: \"You are a helpful assistant\" },\n    { role: \"user\", content: \"Hello\" },\n  ],\n});\n\nconsole.log(response.choices[0].message.content);\n```\n:::\n:::code-tab{label=\"Go\"}\n```go\n\u002F\u002F Standard library only\npackage main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"net\u002Fhttp\"\n\t\"os\"\n)\n\nfunc main() {\n\tpayload := []byte(`{\n\t\t\"model\": \"minimax-m2.5\",\n\t\t\"messages\": [\n\t\t\t{\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n\t\t\t{\"role\": \"user\", \"content\": \"Hello\"}\n\t\t],\n\t\t\"stream\": false\n\t}`)\n\n\treq, err := http.NewRequest(\"POST\", \"https:\u002F\u002Fsilvamux.io\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions\", bytes.NewReader(payload))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treq.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"SILVAMUX_API_KEY\"))\n\treq.Header.Set(\"Content-Type\", \"application\u002Fjson\")\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(string(body))\n}\n```\n:::\n::\n\nResponse (OpenAI format):\n\n```json\n{\n  \"id\": \"chatcmpl-xxxx\",\n  \"choices\": [\n    {\n      \"message\": {\"role\": \"assistant\", \"content\": \"Hello! How can I help you today?\"},\n      \"finish_reason\": \"stop\"\n    }\n  ],\n  \"usage\": {\"prompt_tokens\": 20, \"completion_tokens\": 15, \"total_tokens\": 35}\n}\n```\n\nThe compatible entry passes through extra fields of the corresponding protocol. See [Overview](\u002Fen\u002Fdocs\u002Fmodels\u002Fchat\u002Foverview) for streaming and multimodal input.\n",[],{"title":84,"description":826},"LaqgybyOg3G9RjxXtGnkd7NGO0iv6WgtqHaINiGxzik",{"found":309,"operationId":834,"summary":835,"description":836,"method":160,"path":161,"publiclyDiscoverable":309,"security":837,"parameters":841,"requestBody":842,"responses":873},"createOpenAIChatCompletion","OpenAI Chat Completions","OpenAI Chat Completions 兼容入口，额外字段按模型能力透传。",{"schemes":838,"optional":43},[839,840],"BearerAuth","ApiKeyAuth",[],{"present":309,"required":309,"description":180,"contentType":843,"type":844,"fields":845,"variants":872},"application\u002Fjson","OpenAIChatRequest",[846,849,852,855,858,862,866,869],{"name":847,"type":848,"required":43,"description":180},"max_tokens","integer",{"name":850,"type":851,"required":309,"description":180},"messages","array\u003CMessage>",{"name":853,"type":854,"required":309,"description":180},"messages.content","string | array\u003CFreeFormObject>",{"name":856,"type":857,"required":309,"description":180},"messages.role","string (system | user | assistant | tool)",{"name":859,"type":860,"required":309,"description":861},"model","string","SilvaMux 模型 id 或 alias。",{"name":863,"type":864,"required":43,"description":180,"defaultValue":865},"stream","boolean","false",{"name":867,"type":868,"required":43,"description":180},"temperature","number",{"name":870,"type":871,"required":43,"description":180},"tools","array\u003CFreeFormObject>",[],[874,889],{"status":875,"description":876,"contentType":843,"type":877,"fields":878},"200","OpenAI Chat JSON 或 SSE 响应。","OpenAIChatResponse",[879,881,883,884,886],{"name":880,"type":871,"required":309,"description":180},"choices",{"name":882,"type":860,"required":309,"description":180},"id",{"name":859,"type":860,"required":43,"description":180},{"name":885,"type":860,"required":43,"description":180},"object",{"name":887,"type":888,"required":43,"description":180},"usage","FreeFormObject",{"status":890,"description":891,"contentType":843,"type":892,"fields":893},"default","OpenAI 兼容错误。","OpenAIError",[894,896,899,901],{"name":895,"type":885,"required":309,"description":180},"error",{"name":897,"type":898,"required":43,"description":180},"error.code","string | integer",{"name":900,"type":860,"required":309,"description":180},"error.message",{"name":902,"type":860,"required":43,"description":180},"error.type"]