Chat Completion
curl --request POST \
--url https://fanifyai.com/api/v1/hub/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "deepseek-v4-flash-0731",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}
'import requests
url = "https://fanifyai.com/api/v1/hub/chat/completions"
payload = {
"model": "deepseek-v4-flash-0731",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'deepseek-v4-flash-0731', messages: [{role: 'user', content: 'Hello'}]})
};
fetch('https://fanifyai.com/api/v1/hub/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://fanifyai.com/api/v1/hub/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' => 'deepseek-v4-flash-0731',
'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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://fanifyai.com/api/v1/hub/chat/completions"
payload := strings.NewReader("{\n \"model\": \"deepseek-v4-flash-0731\",\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://fanifyai.com/api/v1/hub/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek-v4-flash-0731\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://fanifyai.com/api/v1/hub/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\": \"deepseek-v4-flash-0731\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11",
"object": "chat.completion",
"created": 1757239231,
"model": "deepseek-v4-flash-0731",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 120,
"total_tokens": 130,
"cost": 0.000041
}
}{
"error": {
"message": "The request input is invalid.",
"code": "invalid_input",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"type": "https://fanifyai.com/docs/hub/errors#unauthorized",
"title": "Unauthorized",
"status": 401,
"code": "unauthorized"
}{
"error": {
"message": "Your available balance does not cover this generation.",
"code": "insufficient_credits",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"error": {
"message": "The requested model was not found.",
"code": "model_not_found",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"error": {
"message": "The requested file has expired or is unavailable.",
"code": "file_expired",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"error": {
"message": "This idempotency key was already used with a different request.",
"code": "idempotency_conflict",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"error": {
"message": "Rate limit reached, retry later.",
"code": "rate_limited",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"error": {
"message": "A generation with this idempotency key is still in progress.",
"code": "generation_in_progress",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}Chat
Chat Completion
Creates a synchronous chat completion from an OpenAI-compatible request. Provider failures preserve an upstream 4xx status when applicable and use the provider_error code; upstream 5xx failures return 503.
POST
/
api
/
v1
/
hub
/
chat
/
completions
Chat Completion
curl --request POST \
--url https://fanifyai.com/api/v1/hub/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "deepseek-v4-flash-0731",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}
'import requests
url = "https://fanifyai.com/api/v1/hub/chat/completions"
payload = {
"model": "deepseek-v4-flash-0731",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'deepseek-v4-flash-0731', messages: [{role: 'user', content: 'Hello'}]})
};
fetch('https://fanifyai.com/api/v1/hub/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://fanifyai.com/api/v1/hub/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' => 'deepseek-v4-flash-0731',
'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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://fanifyai.com/api/v1/hub/chat/completions"
payload := strings.NewReader("{\n \"model\": \"deepseek-v4-flash-0731\",\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://fanifyai.com/api/v1/hub/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek-v4-flash-0731\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://fanifyai.com/api/v1/hub/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\": \"deepseek-v4-flash-0731\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11",
"object": "chat.completion",
"created": 1757239231,
"model": "deepseek-v4-flash-0731",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 120,
"total_tokens": 130,
"cost": 0.000041
}
}{
"error": {
"message": "The request input is invalid.",
"code": "invalid_input",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"type": "https://fanifyai.com/docs/hub/errors#unauthorized",
"title": "Unauthorized",
"status": 401,
"code": "unauthorized"
}{
"error": {
"message": "Your available balance does not cover this generation.",
"code": "insufficient_credits",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"error": {
"message": "The requested model was not found.",
"code": "model_not_found",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"error": {
"message": "The requested file has expired or is unavailable.",
"code": "file_expired",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"error": {
"message": "This idempotency key was already used with a different request.",
"code": "idempotency_conflict",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"error": {
"message": "Rate limit reached, retry later.",
"code": "rate_limited",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}{
"error": {
"message": "A generation with this idempotency key is still in progress.",
"code": "generation_in_progress",
"type": "invalid_request_error",
"metadata": {
"provider_name": "FanifyHub"
}
}
}Autorisations
Fanify API key.
En-têtes
Optional idempotency key, from 1 to 255 characters.
Corps
application/json
OpenAI-compatible chat completion request. Additional top-level fields are forwarded. The stream field must be omitted or false; n is not supported and must be omitted.
Réponse
OpenAI-compatible chat completion.
The response is of type object.
Cette page vous a-t-elle été utile ?
