Quick Start

Get started with Dragonfly market routing in 3 steps.

1

Create an account

Sign up at dragonfly.dev β€” you get $1 free credit.

2

Create access key + routing profile

Go to Dashboard β†’ Access Keys and bind a routing strategy.

3

Make your first matched request

Use any OpenAI-compatible SDK and route through market policy.

curl https://dragonfly-api.com/v1/chat/completions \
  -H "Authorization: Bearer sk-df-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-chat",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Authentication

All requests require a Bearer token in the Authorization header.

Authorization: Bearer sk-df-xxxxxxxxxxxxxxxxxxxx

Get your access key from the Dashboard.

First request failed?

Failure Recovery
When the first request fails, recover by error type instead of retrying blindly.
Verify your email first

Key creation stays locked until email verification completes.

Open verification
Regenerate or re-copy the key

401s usually mean the request is using an old key, a partial copy, or the wrong prefix.

Open buyer keys
Switch to a supported starter model

Use the live starter model instead of cached or outdated examples.

Open quick start
Top up credits

The request path is valid, but the wallet has no spendable balance.

Open wallet
Retry with a fallback route

No eligible seller channel was healthy enough for the current constraints.

Open playground
Refresh and retry

The gateway returned HTML or a mismatched surface instead of JSON.

Open support

Chat Completions

Create a chat completion. OpenAI-compatible.

POST/v1/chat/completions

Request Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g. deepseek/deepseek-chat)
messagesarrayYesArray of message objects with role and content
temperaturenumberNoSampling temperature (0-2). Default: 1
top_pnumberNoNucleus sampling. Default: 1
max_tokensintegerNoMaximum tokens to generate
streambooleanNoStream response via SSE. Default: false
stopstring|arrayNoStop sequences
frequency_penaltynumberNoFrequency penalty (-2 to 2). Default: 0
presence_penaltynumberNoPresence penalty (-2 to 2). Default: 0
toolsarrayNoFunction calling tools (OpenAI format)
tool_choicestring|objectNoTool selection mode

Request Example

curl https://dragonfly-api.com/v1/chat/completions \
  -H "Authorization: Bearer sk-df-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-chat",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is 2+2?"}
    ],
    "temperature": 0.7,
    "max_tokens": 1024
  }'

Response

Response
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1709000000,
  "model": "deepseek/deepseek-chat",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "2 + 2 = 4"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 8,
    "total_tokens": 33
  }
}

Market Routing

Dragonfly operates a market where third-party providers contribute API keys at discounted prices. Routing-Strategy

Routing-Strategy Header

ParameterTypeRequiredDescription
market-onlydefaultNoUse marketplace seller capacity only. Fails with 503 if no eligible seller is available. Requires accepted Trading Terms.

The default strategy is market-only.

If no eligible seller is available, the API returnsmarket_unavailable(503).

Note: market-only requires that you accept the Trading Terms in your Dashboard.

curl https://dragonfly-api.com/v1/chat/completions \
  -H "Authorization: Bearer sk-df-xxx" \
  -H "Content-Type: application/json" \
  -H "Routing-Strategy: market-only" \
  -d '{
    "model": "deepseek/deepseek-chat",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Session Stickiness (Optional)

When using market routing, you can pass an X-Session-Id header to keep consecutive requests routed to the same provider key. This is useful for multi-turn conversations where provider-level context caching may improve latency.

X-Session-Id: my-chat-session-123

Performance Preferences

Latency/throughput constraints are soft by default (affect ranking, not hard rejection). Use hard headers only when strict filtering is required.

ParameterTypeRequiredDescription
X-Max-PriceheaderNoMax acceptable input-side price (hard filter).
X-Max-TTFT-MsheaderNoPreferred max TTFT (soft preference).
X-Min-Throughput-TPSheaderNoPreferred minimum throughput (soft preference).
X-Hard-Max-TTFT-MsheaderNoStrict max TTFT filter.
X-Hard-Min-Throughput-TPSheaderNoStrict minimum throughput filter.
X-Privacy-ModeheaderNoPrivacy filter: trusted_only.

Provider Controls

ParameterTypeRequiredDescription
X-Provider-OnlyheaderNoComma-separated provider allowlist (hard filter).
X-Provider-IgnoreheaderNoComma-separated provider denylist (hard filter).
X-Provider-OrderheaderNoComma-separated provider preference order (soft ranking).

Route Diagnostics Headers

Successful market responses include debug headers for tracing route decisions. These headers are used by the Playground route diagnostics panel.

ParameterTypeRequiredDescription
X-DF-Market-Routeresponse headerNoseller.
X-DF-Market-Providerresponse headerNoMatched provider slug.
X-DF-Market-Listing-Idresponse headerNoMatched listing ID (seller route).
X-DF-Market-Request-Idresponse headerNoMatching request ID.
X-DF-Upstream-Modelresponse headerNoResolved upstream model.
X-DF-Market-Ask-Inputresponse headerNoInput ask price used by settlement.
X-DF-Market-Ask-Outputresponse headerNoOutput ask price used by settlement.
X-DF-Market-Fee-Profile-Idresponse headerNoApplied fee profile ID if available.

List Models

List all available models.

GET/v1/models
curl https://dragonfly-api.com/v1/models
Response
{
  "object": "list",
  "data": [
    {
      "id": "deepseek/deepseek-chat",
      "object": "model",
      "owned_by": "deepseek",
      "pricing": { "input": 0.0005, "output": 0.0015 }
    }
  ]
}

Audio Speech (TTS)

Generate speech from text. Powered by MiniMax.

POST/v1/audio/speech
ParameterTypeRequiredDescription
modelstringYesminimax/speech-02-hd or minimax/speech-02-turbo
inputstringYesText to speak
voicestringNoVoice ID. Default: alloy
speednumberNoSpeed (0.25-4.0). Default: 1.0
curl https://dragonfly-api.com/v1/audio/speech \
  -H "Authorization: Bearer sk-df-xxx" \
  -H "Content-Type: application/json" \
  -d '{"model": "minimax/speech-02-hd", "input": "Hello world", "voice": "alloy"}' \
  --output speech.mp3

Models & Pricing

Prices per million tokens.

DeepSeek

Model IDInputOutputContextCapabilities
deepseek/deepseek-chat$0.50$1.50128KChat, Code
deepseek/deepseek-reasoner$2.00$8.00128KReasoning

MiniMax

Model IDInputOutputContextCapabilities
minimax/minimax-m2.5$0.80$2.401MChat
minimax/minimax-m2.5-highspeed$0.40$1.201MChat (fast)
minimax/speech-02-hdβ€”β€”β€”TTS (HD)
minimax/speech-02-turboβ€”β€”β€”TTS (fast)

Rate Limits

PlanRequests/minTokens/min
Free1040,000
Starter60200,000
Pro3001,000,000
EnterpriseUnlimitedUnlimited

Rate limit headers are included in every response: X-RateLimit-Remaining, X-RateLimit-Reset.

Error Codes

CodeTypeDescription
400bad_requestInvalid request parameters
401unauthorizedMissing or invalid API key
403forbiddenInsufficient balance or permissions
429rate_limit_exceededToo many requests. Retry after X-RateLimit-Reset.
500internal_errorServer error. Retry with exponential backoff.
502upstream_errorUpstream provider error

Error Response Format

Response
{
  "error": {
    "message": "Insufficient balance",
    "type": "forbidden",
    "code": 403
  }
}
Docs β€” Dragonfly / ζ–‡ζ‘£ β€” Dragonfly