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