Back to DadGPT
API Docs

DadGPT API Documentation

Full setup guide for OpenAI-compatible clients, API keys, chat completions, model selection, streaming, and provider-key troubleshooting.

DadGPT OpenAI-Compatible API Reference

This document describes how to use the DadGPT API with agentic coding tools like Cline, Roo Code, Continue, Aider, and other OpenAI-compatible clients.

Quick Start

Base URL

https://your-domain.com/v1

1. Create a DadGPT API Key

  1. Log in to DadGPT.
  2. Go to Settings -> API Keys.
  3. Click Create New API Key.
  4. Copy the key immediately. It is shown only once.

DadGPT API keys start with:

sk-dad_

2. Use the Key in Requests

All API requests require the key in the Authorization header:

Authorization: Bearer sk-dad_your_api_key_here

3. Configure Your Client

Use these values in any OpenAI-compatible app:

SettingValue
ProviderOpenAI-compatible
Base URLhttps://your-domain.com/v1
API Keysk-dad_your_api_key_here
Modeldadgpt-default or dadgpt-beast

Important: User Key vs Provider Key

There are two different API keys involved:

KeyUsed byExamplePurpose
DadGPT API keyAPI userssk-dad_...Authenticates users to DadGPT
Provider API keyDadGPT serverDEEPSEEK_API_KEY, OPENROUTER_API_KEY, DASHSCOPE_API_KEYAuthenticates DadGPT to the upstream model provider

If users see 401 Invalid API key after their sk-dad_... key is accepted, the problem is usually the server-side provider key, not the user's DadGPT key.

Server operators should verify the selected model's configured apiKeyEnv, baseURL, and provider key value.


Endpoints

POST /v1/chat/completions

Generate AI chat completions. Supports both streaming and non-streaming responses.

Request Body

ParameterTypeRequiredDefaultDescription
modelstringNodadgpt-defaultModel to use. Options: dadgpt-default, dadgpt-beast
messagesarrayYes-Array of message objects with role and content
streambooleanNofalseWhether to stream the response
temperaturenumberNo0.9Sampling temperature (0-2)
max_tokensnumberNo4096Maximum tokens to generate
top_pnumberNo0.95Nucleus sampling parameter
frequency_penaltynumberNo0.5Frequency penalty (-2 to 2)
presence_penaltynumberNo0.5Presence penalty (-2 to 2)

Message Object

{
  "role": "user" | "assistant" | "system",
  "content": "Your message here"
}

Example Request

curl -X POST https://your-domain.com/v1/chat/completions \
  -H "Authorization: Bearer sk-dad_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dadgpt-default",
    "messages": [
      {"role": "system", "content": "You are a helpful coding assistant"},
      {"role": "user", "content": "Write a Python function to calculate fibonacci numbers"}
    ],
    "stream": true
  }'

Response (Non-Streaming)

{
  "id": "chatcmpl-abc123xyz",
  "object": "chat.completion",
  "created": 1703123456,
  "model": "dadgpt-default",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here's a Python function..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 150,
    "total_tokens": 175
  }
}

Response (Streaming)

Streaming responses use Server-Sent Events (SSE):

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1703123456,"model":"dadgpt-default","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1703123456,"model":"dadgpt-default","choices":[{"index":0,"delta":{"content":"Here's"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1703123456,"model":"dadgpt-default","choices":[{"index":0,"delta":{"content":" a"},"finish_reason":null}]}

...

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1703123456,"model":"dadgpt-default","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

GET /v1/models

List available models.

Example Request

curl https://your-domain.com/v1/models \
  -H "Authorization: Bearer sk-dad_your_api_key"

Response

{
  "object": "list",
  "data": [
    {
      "id": "dadgpt-default",
      "object": "model",
      "created": 1703123456,
      "owned_by": "dadgpt"
    },
    {
      "id": "dadgpt-beast",
      "object": "model",
      "created": 1703123456,
      "owned_by": "dadgpt"
    }
  ]
}

Models

ModelDescriptionToken Cost
dadgpt-defaultBalanced model for general use1 token/request
dadgpt-beastExtended context, more detailed responses3 tokens/request

Rate Limits

  • Default: 60 requests per minute per API key
  • Rate limit headers are included in responses:
    • X-RateLimit-Limit: Maximum requests per minute
    • X-RateLimit-Remaining: Remaining requests in current window
    • X-RateLimit-Reset: Unix timestamp when the limit resets

Error Responses

All errors follow the OpenAI error format:

{
  "error": {
    "message": "Error description",
    "type": "error_type",
    "param": null,
    "code": "error_code"
  }
}

Error Codes

StatusCodeDescription
401missing_api_keyMissing Authorization: Bearer sk-dad_... header
401invalid_api_keyInvalid DadGPT key, or upstream provider key rejected the selected model request
401api_key_expiredAPI key has expired
402insufficient_quotaInsufficient tokens in account
403account_suspendedAccount has been suspended
429rate_limit_exceededToo many requests
400invalid_requestMalformed request
400model_not_foundInvalid model specified
500internal_errorServer error

Troubleshooting 401 Errors

Missing or invalid DadGPT key

Symptoms:

{
  "error": {
    "code": "missing_api_key"
  }
}

Fix:

-H "Authorization: Bearer sk-dad_your_api_key"

Upstream provider key rejected

Symptoms in server logs:

[API v1] Request: model=deepseek-v4-flash
[API v1] Error: Error: 401 Invalid API key.
code: 'invalid_api_key'

Meaning: the user's DadGPT key passed validation, but the selected model provider rejected the server-side key.

Fix for server operators:

  1. Check the selected model in admin/model config.
  2. Verify apiKeyEnv points to the right env var.
  3. Verify the env var contains a valid provider key.
  4. Verify baseURL matches the provider.
  5. Verify the model name is supported by that provider.

Example env vars:

DEEPSEEK_API_KEY=your_deepseek_key
OPENROUTER_API_KEY=your_openrouter_key
DASHSCOPE_API_KEY=your_dashscope_key

Tool Configurations

Cline (VS Code)

In your VS Code settings (settings.json):

{
  "cline.apiProvider": "openai-compatible",
  "cline.apiBaseUrl": "https://your-domain.com/v1",
  "cline.apiKey": "sk-dad_your_api_key_here",
  "cline.model": "dadgpt-default"
}

Roo Code

{
  "roo.provider": "openai-compatible",
  "roo.baseUrl": "https://your-domain.com/v1",
  "roo.apiKey": "sk-dad_your_api_key_here",
  "roo.model": "dadgpt-default"
}

Continue

In your Continue configuration (~/.continue/config.json):

{
  "models": [
    {
      "title": "DadGPT",
      "provider": "openai",
      "model": "dadgpt-default",
      "apiBase": "https://your-domain.com/v1",
      "apiKey": "sk-dad_your_api_key_here"
    }
  ]
}

Aider

export OPENAI_API_BASE=https://your-domain.com/v1
export OPENAI_API_KEY=sk-dad_your_api_key_here
aider --model dadgpt-default

OpenAI Python SDK

from openai import OpenAI

client = OpenAI(
    api_key="sk-dad_your_api_key_here",
    base_url="https://your-domain.com/v1"
)

response = client.chat.completions.create(
    model="dadgpt-default",
    messages=[
        {"role": "user", "content": "Hello!"}
    ],
    stream=True
)

for chunk in response:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

curl

curl -X POST https://your-domain.com/v1/chat/completions \
  -H "Authorization: Bearer sk-dad_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dadgpt-default",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Best Practices

  1. Keep your API key secure - Never commit API keys to version control
  2. Use environment variables - Store keys in environment variables, not code
  3. Handle rate limits - Implement exponential backoff for 429 responses
  4. Use streaming for long responses - Streaming provides better UX for code generation
  5. Monitor your usage - Check the Settings page for API usage statistics

Support

  • Telegram: @Automax_0
  • Issues: Create an issue on GitHub