BLACKFUEL
API Reference

Rate Limits

The rate-limit headers the Blackfuel API returns, how to back off when you hit a limit, and the request body and context-window limits

How Rate Limiting Works

When you exceed a rate limit, the API returns a 429 Too Many Requests response.

Rate Limit Headers

The inference endpoints — POST /v1/chat/completions, POST /v1/messages and POST /v1/embeddings — return rate-limit headers on both successful and 429 responses.

HeaderDescription
x-ratelimit-remainingRequests remaining in the current window
x-ratelimit-resetWhole seconds remaining in the current window
retry-after429 with code: rate_limit_exceeded — whole seconds until the quota window resets

Read x-ratelimit-remaining and x-ratelimit-reset for the state that applies to your request. On a 429 with code: rate_limit_exceeded, retry-after carries the whole seconds until the quota window resets — the same value as x-ratelimit-reset — so clients can honour the retry interval directly from the standard header.

Handling Rate Limits

On a 429, wait the retry-after seconds when the header is present, otherwise back off exponentially. For the full error taxonomy and retry guidance, see the Error Handling guide.

import os
import time
import openai
from openai import RateLimitError

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

def chat_with_retry(messages, max_retries=5):
    for attempt in range(max_retries):
        try:
            return client.chat.completions.create(
                model="deepseek-ai/DeepSeek-V4-Flash-0731",
                messages=messages
            )
        except RateLimitError as e:
            if attempt == max_retries - 1:
                raise

            # Exponential backoff
            wait_time = (2 ** attempt) + 1
            print(f"Rate limited. Waiting {wait_time}s...")
            time.sleep(wait_time)
import OpenAI from 'openai';

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

async function chatWithRetry(messages, maxRetries = 5) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      return await client.chat.completions.create({
        model: 'deepseek-ai/DeepSeek-V4-Flash-0731',
        messages
      });
    } catch (error) {
      if (error.status !== 429 || attempt === maxRetries - 1) {
        throw error;
      }

      // Exponential backoff
      const waitTime = Math.pow(2, attempt) + 1;
      console.log(`Rate limited. Waiting ${waitTime}s...`);
      await new Promise(r => setTimeout(r, waitTime * 1000));
    }
  }
}

Staying Within Your Limits

The Best Practices guide covers the levers that keep your request rate down: streaming, response caching, prompt sizing, and concurrency control.

Error Response

The OpenAI SDKs map the status onto their rate-limit error, so except RateLimitError in Python and error.status === 429 in JavaScript both work. For the error object, see the Error Handling guide.

Request Limits

A request body may be at most 16,777,216 bytes (16 MiB), on every endpoint and model. The limit counts the whole serialized body, including the conversation history you resend and any image sent inline as a data: URI. A larger body returns 413 Payload Too Large.

The prompt must also fit the model's context window: its context_length, in tokens, from GET /v1/models or Available Models.

On a 413, shrink the request before retrying: drop or summarize earlier turns, pass images by HTTPS URL rather than inline (see Vision), or split the work across several requests.

Need Higher Rate Limits?

To request higher rate limits for your use case, email [email protected].

On this page