Create a chat completion
curl --request POST \
--url https://api.bianxie.ai/v1/chat/completionsimport requests
url = "https://api.bianxie.ai/v1/chat/completions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.bianxie.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.bianxie.ai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.bianxie.ai/v1/chat/completions"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.bianxie.ai/v1/chat/completions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bianxie.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyOpenAI
Create a chat completion
Generate a reply from a list of messages
POST
/
v1
/
chat
/
completions
Create a chat completion
curl --request POST \
--url https://api.bianxie.ai/v1/chat/completionsimport requests
url = "https://api.bianxie.ai/v1/chat/completions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.bianxie.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.bianxie.ai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.bianxie.ai/v1/chat/completions"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.bianxie.ai/v1/chat/completions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bianxie.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyAuthenticate with a Bearer API key and send JSON.
A non-streaming response contains
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID from the live model page. |
messages | array | Yes | Ordered system, developer, user, assistant, or tool messages; content may be text or content parts. |
temperature, top_p | number | No | Sampling controls; normally adjust only one. |
max_completion_tokens | integer | No | Maximum generated tokens. |
stream | boolean | No | Return SSE deltas. Default false. |
stop | string/array | No | Stop sequences, subject to model support. |
n | integer | No | Number of choices. |
presence_penalty, frequency_penalty | number | No | Topic and repetition controls. |
response_format | object | No | Text, JSON object, or JSON Schema output. |
tools, tool_choice | mixed | No | Tool definitions and selection policy. |
seed, user, metadata | mixed | No | Reproducibility hint, user ID, and metadata, subject to model support. |
curl https://api.bianxie.ai/v1/chat/completions \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "your-model",
"messages": [{"role": "user", "content": "Hello"}],
"temperature": 0.7
}'
client.chat.completions.create(model="your-model", messages=[{"role":"user","content":"Hello"}])
await client.chat.completions.create({ model: "your-model", messages: [{ role: "user", content: "Hello" }] });
id, object, created, model, choices[], and usage. Each choice has index, message, and finish_reason. Streaming responses provide choices[].delta increments.⌘I
