Skip to content
Heimdallm
Marketplace/Documentation
Documentation · API reference

Completions

POST https://api-staging.impossiblecarrot.cc/api/v1/completions

The older OpenAI text-completions shape — prompt in, text out — kept deliberately because many SDKs and tools still speak it. It is one thin route over the same inference core as chat. Requires a bearer API key. Routing, fallbacks and provider preferences work exactly as on chat completions. Set "stream": true for text deltas over SSE. Not every endpoint serves this API; one that does not answers 502.

Request body

FieldTypeNotes
modelstringModel id, optionally with a routing suffix. Required unless models is given.
modelsstring[] (≤ 20)Fallback model list.
promptstring / string[]Required. An array is joined with newlines for cost estimation and sent as is.
streambooleanEmit text deltas over SSE. Defaults to false.
temperaturenumber0 to 2.
top_pnumberGreater than 0 and at most 1. Zero returns 400; it is not replaced with a default.
top_kinteger≥ −1; -1 disables this filter where the endpoint declares it.
frequency_penaltynumber−2 to 2.
presence_penaltynumber−2 to 2.
repetition_penaltynumberGreater than 0 and at most 2; requires endpoint declaration.
seedintegerBest-effort determinism.
stopstring / string[]Up to 8 stop sequences.
max_tokensintegerCompletion ceiling, 1 to 1,048,576; also bounds the credit hold.
logprobsinteger / null0 to 5.
echobooleanReturn the prompt with the completion, where supported.
suffixstringText after the insertion point, where supported.
userstring (≤ 256)Opaque end-user identifier.
providerobjectProvider preferences.
routestringDeprecated routing alias: fallback groups by model; sort orders across models. Explicit provider.sort.partition takes precedence.

The adapter forwards known text-completion fields. top_k and repetition_penalty require an endpoint declaration in supported_parameters. Chat-only members, marketplace routing preferences and unknown members are omitted from the upstream body.

Example

curl https://api-staging.impossiblecarrot.cc/api/v1/completions \
-H "Authorization: Bearer $HEIMDALL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "model": "deepseek/deepseek-v4-flash-0731-abliterated",
  "prompt": "The three smallest primes are",
  "max_tokens": 16
}'
{
  "id": "gen-41d0aa2b9c3e",
  "object": "text_completion",
  "created": 1755300000,
  "model": "deepseek/deepseek-v4-flash-0731-abliterated",
  "provider": "ImpCC",
  "choices": [
    {
      "index": 0,
      "text": " 2, 3 and 5.",
      "finish_reason": "stop",
      "native_finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 6,
    "completion_tokens": 8,
    "total_tokens": 14,
    "cost": 0.0000038
  }
}

Response fields

FieldTypeNotes
idstringThe generation id; also the X-Generation-Id header.
objectstringtext_completion.
createdintegerUnix seconds.
modelstringThe model that served the request.
providerstringThe serving provider's display name. (Heimdallm)
choices[].textstringThe completion text.
choices[].finish_reasonstringstop, length, tool_calls, content_filter or error.
choices[].native_finish_reasonstringThe provider's raw finish reason.
choices[].logprobsobjectPresent when requested and supported.
usageobjectToken counts and cost in USD, as on chat completions.

Streaming

Set "stream": true and use curl -N to read each frame as it arrives. Each data: frame contains an object with object: "text_completion"; append each choice's text to that choice's answer. The final successful chunk has empty choices and carries usage, including cost, before data: [DONE] ends the stream. Usage is based on provider measurements; missing usage is not a measured zero.

A failure before the stream commits returns an ordinary HTTP error. After commitment, the final error frame follows the chat error convention: a chat.completion.chunk with error and choices[0].finish_reason: "error", followed by [DONE]. Usage observed before a failure is settled by the same billing rules as chat. A partial answer is never continued by another provider.

X-Generation-Id identifies both response formats. Successful non-streaming replies also carry X-Provider-Name; streamed chunks carry the serving provider in provider.

DiscoverFind your next modelModel libraryAll models, versions, prices and capabilitiesBenchmarksMeasured quality, cost and time by serving configurationShowcaseImages, video and 3D made on the marketplaceProvidersCompare independent inference providersActivityMarketplace traffic and usageNetwork statusAvailability, latency and endpoint healthChatConversations, model settings and filesImage, video & 3DGenerate images, video and 3D assetsScene studioStage a shot in 3D, direct it and render it as a videoCoding playgroundBuild software with an AI agent on a machine of your ownOverview & routingIdentity, workspaces and routing preferencesCredits & billingBalance, deposits, ledger and reserved fundsAPI keysKeys scoped to workspaces, limits and expirationOrganizationsTeams, members and shared workspacesRequest historyRequests, receipts, sandbox sessions and account historyReferralsInvitations and referral earningsPrivacyData settings, exports and deletionDocumentationQuickstart, SDKs, pricing and guidesAPI referenceInteractive endpoint reference