Skip to content

API Reference

Base URL

https://gateway.datahippo.io/v1

Endpoints

POST /chat/completions

Create a chat completion. Supports both streaming and non-streaming responses.

Full path: POST /api/gateway/v1/chat/completions

Request Body

json
{
  "model": "gpt-4o",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "temperature": 0.7,
  "max_tokens": 1024,
  "stream": false
}
FieldTypeRequiredDescription
modelstringYesModel identifier (e.g., "gpt-4o", "claude-3-5-sonnet", "auto").
messagesarrayYesArray of message objects. Max 1000 messages, max 1MB per message.
temperaturenumberNoSampling temperature, 0.0–2.0. Higher values produce more random output.
max_tokensintegerNoMaximum tokens to generate. Max 1,000,000.
top_pnumberNoNucleus sampling threshold, 0.0–1.0.
nintegerNoNumber of completions to generate. Max 10.
streambooleanNoIf true, response is streamed as Server-Sent Events.
stopstring or arrayNoStop sequence(s) where generation halts.
frequency_penaltynumberNoFrequency penalty, -2.0–2.0.
presence_penaltynumberNoPresence penalty, -2.0–2.0.
userstringNoEnd-user identifier for abuse monitoring.
seedintegerNoSeed for deterministic sampling.
toolsarrayNoTool/function definitions the model may call.
tool_choicestring or objectNoControls tool usage: "none", "auto", "required", or a specific function.
response_formatobjectNoResponse format: {"type": "text"}, {"type": "json_object"}, or {"type": "json_schema"}.
thinkingobjectNoExtended thinking config: {"type": "enabled", "budget_tokens": 10000}.
reasoning_effortstringNoFor o-series models: "low", "medium", or "high".
prompt_configstringNoName of a Flow prompt config to apply. Alternative to the X-DataHippo-Prompt-Config header.
prompt_variablesobjectNoTemplate variables for the managed prompt. Alternative to X-DataHippo-Var-* headers.

Message Object

FieldTypeRequiredDescription
rolestringYes"system", "user", "assistant", or "tool".
contentstring or arrayYesText content or array of content parts (for multimodal).
namestringNoAuthor name for multi-user conversations.
tool_callsarrayNoTool calls made by the assistant.
tool_call_idstringNoFor tool messages: ID of the tool call being responded to.

Content Parts (Multimodal)

When content is an array, each element is a content part:

json
[
  {"type": "text", "text": "What's in this image?"},
  {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}},
  {"type": "document_url", "document_url": {"url": "data:application/pdf;base64,..."}}
]

Response (Non-Streaming)

json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 10,
    "total_tokens": 35
  }
}

Response (Streaming)

When stream: true, the response is a stream of SSE events:

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1700000000,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1700000000,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1700000000,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":25,"completion_tokens":2,"total_tokens":27}}

data: [DONE]

GET /models

List supported model prefixes.

Full path: GET /api/gateway/v1/models


Request Headers

Required

HeaderDescription
AuthorizationBearer dh_your_key — your DataHippo API key.

Optional

HeaderDescription
X-DataHippo-Prompt-ConfigName of the prompt config to apply. Alternative to the prompt_config body field.
X-DataHippo-Session-IdSession identifier for session budgets and session-sticky rollout allocation.
X-DataHippo-User-IdUser identifier for user-sticky rollout allocation.
X-DataHippo-Force-VariantForce a rollout variant: "target" or "baseline". For debugging only.
X-DataHippo-Var-{name}Template variable value. Header name is normalized: x-datahippo-var-user-name becomes user_name. Max 255 characters per value.

Response Headers

HeaderDescription
x-datahippo-providerProvider that served the response (e.g., openai, anthropic).
x-datahippo-model-usedModel that generated the response.
x-datahippo-original-modelOriginal requested model (present when failover occurred).
x-datahippo-fallback-used"true" when a fallback provider was used.
x-datahippo-retry-countNumber of retries before the request succeeded.
x-datahippo-cacheCache status: "hit", "miss", or "skip".
x-datahippo-warningWarning message (e.g., explicit mode but no prompt_config sent).
x-output-contract-violation"true" when the response failed output schema validation but was passed through.
x-request-idUnique request ID for tracing and correlation.

Error Responses

Errors follow a standard format:

json
{
  "error": {
    "message": "Description of what went wrong",
    "type": "error_type",
    "code": "error_code"
  }
}
HTTP StatusCondition
400Validation error (empty messages, invalid temperature, etc.)
401Missing or invalid API key / project ID
404Prompt config not found
422Template variable validation failed
429Session budget exceeded
500Provider error or internal failure
503Provider unavailable after retries and failover

DataHippo Documentation