DINGJIAI
DINGJIAI
Quick start in 5 minutesWhat is DINGJIAI?

Online use

Online chatOpens in a new windowImage generationOpens in a new window

Popular Agents

Codex SetupClaude Code SetupOne-Click Setup

API Reference

API overview
ResponsesChat CompletionsAnthropic MessagesGemini API
Error codes

Billing

Model pricingTroubleshooting calls
API families and API entries

Gemini API

Gemini GenerateContent and StreamGenerateContent operations, model lists, authentication, and usage billing boundaries.

Gemini is a native API family entry

Clients use the native Google Gemini API family paths. generateContent and streamGenerateContent are the non-streaming and streaming operations. DINGJIAI selects the model product and upstream capability for the operation, forwards the request, reads usageMetadata, and settles billing.

Paths

Gemini exposes two generation operations: GenerateContent returns a complete result, while StreamGenerateContent returns native Gemini streaming events. Both share Gemini authentication, model products, and upstream capability selection, but use different paths and delivery modes.

API family / operationMethod and path
Gemini API · GenerateContentPOST /v1beta/models/{model}:generateContent
Gemini API · StreamGenerateContentPOST /v1beta/models/{model}:streamGenerateContent
Gemini API · model listGET /v1beta/models or GET /v1beta/models/

Generation paths must include the /v1beta/models/{model}: prefix. {model} may be gemini-2.5-flash or models/gemini-2.5-flash; the gateway normalizes the models/ prefix inside the model value. Model-list responses use the Gemini-style models/{publicModel} form.

Authentication

Put your user key in x-goog-api-key

x-goog-api-key must contain your DINGJIAI user API key, not a Google provider key.

See Base URL and authentication and Headers for the complete header rules. Examples on this page use x-goog-api-key. Bearer is supported only for compatibility; x-api-key and the URL ?key= form are rejected.

Non-streaming request

POST /v1beta/models/{model}:generateContent
curl https://dingjiai.com/v1beta/models/gemini-2.5-flash:generateContent \
  -H "x-goog-api-key: YOUR_USER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      { "role": "user", "parts": [{ "text": "Introduce the DINGJIAI gateway in one sentence" }] }
    ]
  }'

The request-body model and stream fields do not select the DINGJIAI model. The path {model} is authoritative.

Streaming request

POST /v1beta/models/{model}:streamGenerateContent
curl -N https://dingjiai.com/v1beta/models/gemini-2.5-flash:streamGenerateContent \
  -H "x-goog-api-key: YOUR_USER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      { "role": "user", "parts": [{ "text": "List three integration notes" }] }
    ]
  }'

Streaming must use streamGenerateContent. Setting "stream": true in a generateContent request returns stream_not_supported.

usageMetadata and settlement

Prop

Type

Both response modes prefer upstream usageMetadata; streaming keeps the last valid value. If usage is missing or invalid, generated text, thoughts, and functionCall output may contribute to estimation. A valid non-streaming token-priced success JSON object receives at least one output token when usage is missing or invalid, even when no output can be extracted (including {}). Streaming estimation requires extractable model output. Disconnects, cancellations, and delivery failures are not necessarily zero-cost. See Usage and billing for the complete rules.

Gemini image products do not use token usageMetadata; they are billed by the number of valid images actually returned. No valid image means failure settlement with zero charge.

Model list

GET /v1beta/models
curl https://dingjiai.com/v1beta/models \
  -H "x-goog-api-key: YOUR_USER_API_KEY"

The list contains Gemini products that are visible for the current entry, enabled, and have an available upstream candidate. Token products include generateContent and streamGenerateContent in supportedGenerationMethods; per_image products support only generateContent. Streaming support must therefore be read from each returned model product.

Last updated on

Anthropic MessagesCodex Search capability

On this page

PathsAuthenticationNon-streaming requestStreaming requestusageMetadata and settlementModel list