BLACKFUEL
API Reference

Chat Completions

Create chat completions using Blackfuel's available models

POST /v1/chat/completions

This endpoint implements the OpenAI Chat Completions API, so OpenAI client libraries work against it.

Request

Headers

HeaderRequiredDescription
AuthorizationYesBearer token with your API key
Content-TypeYesMust be application/json

Body Parameters

ParameterTypeRequiredDescription
modelstringYesModel identifier (e.g., deepseek-ai/DeepSeek-V4-Flash-0731)
messagesarrayYesArray of message objects
streambooleanNoEnable streaming responses (default: false)
stream_optionsobjectNoAccepted for OpenAI compatibility. See Token Usage
max_tokensintegerNoMaximum tokens to generate
temperaturenumberNoSampling temperature (0.0 - 2.0, default: 1.0)
top_pnumberNoNucleus sampling (0.0 - 1.0, default: 1.0)
top_kintegerNoTop-k sampling (default: -1, disabled)
stopstring/arrayNoStop sequences
seedintegerNoRandom seed for reproducibility
frequency_penaltynumberNoReduce repetition (-2.0 - 2.0, default: 0)
presence_penaltynumberNoEncourage new topics (-2.0 - 2.0, default: 0)
logprobsbooleanNoReturn log probabilities
top_logprobsintegerNoNumber of top logprobs to return (0-20)
toolsarrayNoFunction definitions for tool calling
tool_choicestring/objectNoControl tool calling behavior
response_formatobjectNoConstrain the reply to JSON or to a JSON schema. See Structured Output
reasoning_effortstringNoReasoning depth for reasoning-capable models: none, minimal, low, medium, high, xhigh, max. Send only a level the model lists in its supported_efforts. See the Reasoning guide.

Message Object

FieldTypeRequiredDescription
rolestringYessystem, user, assistant, or tool
contentstring/arrayYesMessage content (text or multimodal)
namestringNoName of the participant
tool_callsarrayNoTool calls made by assistant
tool_call_idstringNoID of the tool call being responded to

Code Examples

import os
import openai

client = openai.OpenAI(
    base_url="https://api.blackfuel.ai/v1",
    api_key=os.environ["BLACKFUEL_API_KEY"],
)

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Flash-0731",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
    max_tokens=500,
    temperature=0.7
)

print(response.choices[0].message.content)
print(f"Tokens used: {response.usage.total_tokens}")
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.blackfuel.ai/v1',
  apiKey: process.env.BLACKFUEL_API_KEY
});

const response = await client.chat.completions.create({
  model: 'deepseek-ai/DeepSeek-V4-Flash-0731',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'Explain quantum computing in simple terms.' }
  ],
  max_tokens: 500,
  temperature: 0.7
});

console.log(response.choices[0].message.content);
console.log(`Tokens used: ${response.usage.total_tokens}`);
curl -X POST https://api.blackfuel.ai/v1/chat/completions \
  -H "Authorization: Bearer $BLACKFUEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-ai/DeepSeek-V4-Flash-0731",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
    "max_tokens": 500,
    "temperature": 0.7
  }'

Response

Success Response

200 OK
{
  "id": "chatcmpl-abc123def456",
  "object": "chat.completion",
  "created": 1703123456,
  "model": "deepseek-ai/DeepSeek-V4-Flash-0731",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum computing is a type of computing that uses quantum mechanics..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 142,
    "total_tokens": 167
  }
}

Response Fields

FieldTypeDescription
idstringUnique identifier for the completion
objectstringAlways "chat.completion"
createdintegerUnix timestamp
modelstringModel used for completion
choicesarrayArray of completion choices
usageobjectToken usage statistics

Choice Object

FieldTypeDescription
indexintegerIndex of this choice
messageobjectThe generated message
finish_reasonstringWhy generation stopped

The generated message also carries reasoning: the model's thinking pass when it reasoned, or null when it did not. See Reasoning.

Finish Reasons

ReasonDescription
stopNatural stop or stop sequence reached
lengthMax tokens limit reached
tool_callsModel invoked a tool
content_filterContent was filtered

Error Responses

To read an error response and decide whether to retry, follow Error Handling.

Tool Calling

Enable function calling by providing tool definitions:

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Flash-0731",
    messages=[
        {"role": "user", "content": "What's the weather in Paris?"}
    ],
    tools=[
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "Get current weather for a city",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city": {"type": "string", "description": "City name"}
                    },
                    "required": ["city"]
                }
            }
        }
    ],
    tool_choice="auto"
)

# Check if the model wants to call a tool
if response.choices[0].message.tool_calls:
    tool_call = response.choices[0].message.tool_calls[0]
    print(f"Function: {tool_call.function.name}")
    print(f"Arguments: {tool_call.function.arguments}")

Vision (Multimodal)

To send an image, pass a content array combining a text part and an image_url part. image_url.url takes a data: URI, or an HTTPS URL the service can fetch. Replace the URL below with your own image.

A model accepts image input when its input_modalities includes image in GET /v1/models; sending an image to any other model returns a 400. An image_url the service cannot fetch returns a 422.

response = client.chat.completions.create(
    model="google/gemma-4-31B-it",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What's in this image?"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://example.com/image.jpg"
                    }
                }
            ]
        }
    ],
    max_tokens=300
)

A non-streaming request that produces no response before the response timeout fails with a 524. Use streaming for any request that may run that long, and to receive tokens as they're generated.

On this page