Chat Completion
curl --request POST \
--url https://apiif.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apiif.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apiif.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ]\n}")
.asString();const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'gpt-4o', messages: [{role: 'user', content: 'Hello'}]})
};
fetch('https://apiif.com/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://apiif.com/v1/chat/completions';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'gpt-4o', messages: [{role: 'user', content: 'Hello'}]})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apiif.com/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",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-4o',
'messages' => [
[
'role' => 'user',
'content' => 'Hello'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}$headers=@{}
$headers.Add("Authorization", "Bearer <token>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://apiif.com/v1/chat/completions' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'import requests
url = "https://apiif.com/v1/chat/completions"
payload = {
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)require 'uri'
require 'net/http'
url = URI("https://apiif.com/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyimport Foundation
let parameters = [
"model": "gpt-4o",
"messages": [
[
"role": "user",
"content": "Hello"
]
]
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://apiif.com/v1/chat/completions")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self)){
"code": 200,
"data": {
"id": "chatcmpl-9876543210",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The history of artificial intelligence (AI) dates back to the 1950s..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 320,
"total_tokens": 348
}
}
}{
"error": {
"code": 400,
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}{
"error": {
"code": 401,
"message": "Authentication failed, please check your API key",
"type": "authentication_error"
}
}{
"error": {
"code": 402,
"message": "Insufficient account balance, please recharge",
"type": "payment_required"
}
}{
"error": {
"code": 403,
"message": "Access forbidden, you don't have permission to access this resource",
"type": "permission_error"
}
}{
"error": {
"code": 429,
"message": "Too many requests, please try again later",
"type": "rate_limit_error"
}
}{
"error": {
"code": 500,
"message": "Internal server error, please try again later",
"type": "server_error"
}
}{
"error": {
"code": 502,
"message": "Bad gateway, service temporarily unavailable",
"type": "bad_gateway"
}
}Text Series
Chat Completion
Create a chat completion using the specified model. Supports multi-turn conversation, streaming, and a variety of generation parameters.
POST
/
v1
/
chat
/
completions
Chat Completion
curl --request POST \
--url https://apiif.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apiif.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apiif.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ]\n}")
.asString();const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'gpt-4o', messages: [{role: 'user', content: 'Hello'}]})
};
fetch('https://apiif.com/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://apiif.com/v1/chat/completions';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'gpt-4o', messages: [{role: 'user', content: 'Hello'}]})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apiif.com/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",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-4o',
'messages' => [
[
'role' => 'user',
'content' => 'Hello'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}$headers=@{}
$headers.Add("Authorization", "Bearer <token>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://apiif.com/v1/chat/completions' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'import requests
url = "https://apiif.com/v1/chat/completions"
payload = {
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)require 'uri'
require 'net/http'
url = URI("https://apiif.com/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyimport Foundation
let parameters = [
"model": "gpt-4o",
"messages": [
[
"role": "user",
"content": "Hello"
]
]
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://apiif.com/v1/chat/completions")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self)){
"code": 200,
"data": {
"id": "chatcmpl-9876543210",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The history of artificial intelligence (AI) dates back to the 1950s..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 320,
"total_tokens": 348
}
}
}{
"error": {
"code": 400,
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}{
"error": {
"code": 401,
"message": "Authentication failed, please check your API key",
"type": "authentication_error"
}
}{
"error": {
"code": 402,
"message": "Insufficient account balance, please recharge",
"type": "payment_required"
}
}{
"error": {
"code": 403,
"message": "Access forbidden, you don't have permission to access this resource",
"type": "permission_error"
}
}{
"error": {
"code": 429,
"message": "Too many requests, please try again later",
"type": "rate_limit_error"
}
}{
"error": {
"code": 500,
"message": "Internal server error, please try again later",
"type": "server_error"
}
}{
"error": {
"code": 502,
"message": "Bad gateway, service temporarily unavailable",
"type": "bad_gateway"
}
}Authorizations
All endpoints require Authorization: Bearer YOUR_API_KEY.
Body
application/json
Model name (e.g. gpt-4o, gpt-5, claude-opus-4-1-20250805).
List of conversation messages.
Show child attributes
Show child attributes
Controls output randomness (0-2). Default: 1.0
Maximum number of tokens to generate.
Whether to use streaming output (SSE). Default: false
Nucleus sampling parameter (0-1). Default: 1.0
Frequency penalty (-2.0 to 2.0). Default: 0
Presence penalty (-2.0 to 2.0). Default: 0
Stop sequences (up to 4).
Number of completions to generate. Default: 1
⌘I