# Clanker Cloud Inference API

Scope: Hosted inference API contract. Model and entitlement behavior here is specific to this endpoint, not an inventory of every Workspace model.

[Choose the right Clanker surface](https://clankercloud.ai/agent.md) · [Workspace FAQ](https://clankercloud.ai/faq.md)

Use this page when you need the public Clanker Cloud hosted inference contract. Standard accounts with spendable subscription or additional credits use the Gemini Developer API route. Business protected and separately contracted sovereign routes fail closed until their environment is active, then use only the approved regional Vertex AI route.

## Endpoint

Use this URL with a dedicated Workspace inference API key.

```text
POST https://api.clankercloud.ai/v1/inference/chat/completions
```

Existing account tokens and contracted protected or sovereign clients continue to use the [original Gateway endpoint](https://clanker-auth-gw-zc0ce3o.uk.gateway.dev/v1/inference/chat/completions).

## Authentication

Eligible personal Workspaces can create a dedicated `clinf_` key in [Account → Inference API keys](https://workspace.clankercloud.ai/#page=account&section=inference-keys). Use either header below. The branded endpoint accepts dedicated inference keys and Standard processing. Supply the credential in the header.

```text
X-API-Key: <token>
Authorization: Bearer <token>
```

Use the signed-in account or an existing account token to read the authenticated `/v1/account` response before assuming no-subscription access. Only `capabilities.noSubscriptionInference: true` authoritatively enables Standard inference for an account without a subscription; old, missing, or false capability responses retain subscription-required compatibility behavior. When enabled, a no-subscription account can spend welcome, purchased, or other additional credits. With an active subscription, subscription credits are consumed before additional credits; without one, additional credits are consumed first. Requests without any spendable balance are rejected before they reach a hosted model backend. Existing protected and separately contracted sovereign accounts receive `409 protected inference is not active` until their contracted environment is active; the service does not downgrade those requests to Standard.

New Business subscriptions use Standard processing until separate enrollment and verified Gemini ZDR activation. Purchasing Business does not automatically select a protected or ZDR processing profile. Existing protected boundaries remain enforced.

## Current provider scope

- Standard inference uses the Google Gemini Developer API for account tokens with spendable credits. No-subscription use additionally requires `capabilities.noSubscriptionInference: true` on `/v1/account`; when enabled, welcome or purchased additional credits can fund the request. `provider` is optional; `gemini`, `google`, and `google-gemini` select that Standard route.
- On an activated protected or sovereign account, the server ignores a client request to select the Standard provider and uses only the contracted regional Vertex AI project, region, and model allowlist.
- `model` remains a free-form string for schema compatibility, but protected model selection is constrained by the server-side allowlist.
- Protected and sovereign activation is not currently available through self-service or the public admin API. Until the private data plane and activation preflight ship, those requests return `409`.

## Curl example

```bash
curl -sS --max-time 130 "https://api.clankercloud.ai/v1/inference/chat/completions" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $CLANKER_CLOUD_API_KEY" \
  -d '{
    "provider": "gemini",
    "model": "gemini-3.5-flash",
    "messages": [
      { "role": "user", "content": "Explain this alert in one sentence." }
    ],
    "metadata": { "source": "external-client" }
  }'
```

## Request shape

```json
{
  "provider": "gemini",
  "model": "gemini-3.5-flash",
  "messages": [
    { "role": "system", "content": "Keep replies concise." },
    { "role": "user", "content": "Summarize this incident." }
  ],
  "metadata": { "source": "external-client" }
}
```

## Response shape

```json
{
  "id": "llm_...",
  "object": "chat.completion",
  "created": 1782100000,
  "model": "gemini-3.5-flash",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ]
}
```

## Current behavior and limits

- Omit `stream` for a normal JSON completion. `stream: true` requests OpenAI-style server-sent events. The shared Gateway currently buffers responses, so events may arrive together.
- When `/v1/account` reports `capabilities.noSubscriptionInference: true`, no-subscription accounts can spend welcome, purchased, or other additional credits. Missing or false capability values retain subscription-required compatibility behavior. Requests without any spendable balance are rejected before model routing.
- Protected and sovereign accounts without an active contracted environment receive `409` with no Standard-provider fallback.
- Non-Gemini provider strings are not available on Standard. Activated protected routes use their server-approved regional Vertex AI configuration.
- The endpoint receives chat messages for hosted inference. Optional client `metadata` is accepted for compatibility but is not persisted or forwarded; the service records only a fixed safe server-generated subset. It does not receive cloud-provider credentials.
- The old desktop-app LLM path remains separate for backward compatibility.

## Timeouts and incomplete responses

Set the client request timeout to about 130 seconds. The inference service allows up to about 110 seconds for server-side processing. The Gateway deadline covers the full response, including streams.

- Check the finish reason before using the answer. A `length` finish reason, Gemini's `MAX_TOKENS`, or HTTP 422 with code `inference_output_exhausted` means the model reached its output budget. Treat any partial text as incomplete. Increase `max_tokens` within the model's limits or split the work into smaller requests.
- For streaming responses, check the finish reason and wait for `data: [DONE]`. A missing terminal marker or an error chunk means the stream is incomplete, even if the HTTP status was 200.
- HTTP 502 and 504 indicate a server or Gateway failure. Keep the status, response code, and request ID when available so support can trace the request.
