AskPuck
Docs / API

API

OpenAI-compatible. Same account and same credits as the app. Point any OpenAI SDK at AskPuck and change the model name.

BASEhttps://askpuck.app/v1

Authentication#

Create a key in Dashboard → API keys. It's shown once. Send it as a Bearer token:

Header
Authorization: Bearer sk-puck-…

A key spends your credits. Keep it on a server, never in a web page or in git.

Chat completions#

POSThttps://askpuck.app/v1/chat/completions
curl https://askpuck.app/v1/chat/completions \
  -H "Authorization: Bearer $PUCK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "puck-cortex-1.2",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Body

FieldWhat it does
modelrequiredstringpuck-cortex-1.2. See Models.
messagesrequiredarrayThe chat so far, in OpenAI format: system, user, assistant.
streamoptionalbooleanSend tokens as they arrive (server-sent events). The last chunk carries usage.
max_tokensoptionalintegerCap on the reply. Held to 256k and to what's left of the 1M window.

Response

200 OK · example
{
  "object": "chat.completion",
  "model": "cortex-1.2",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "Hi! What are we building?" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 9, "completion_tokens": 8, "total_tokens": 17 }
}

Streaming#

With "stream": true the reply comes as data: lines, one chunk each, closed by data: [DONE]. Closing the request cancels the call: you pay only for tokens already made.

List models#

GEThttps://askpuck.app/v1/models
200 OK
{
  "object": "list",
  "data": [
    { "id": "cortex-1.2", "context_length": 1048576, "max_output_tokens": 256000 }
  ]
}

Errors and limits#

Errors come in the OpenAI shape: {"error": {"message", "type", "code"}}.

StatusTypeWhen
400invalid_request_errorThe body isn't valid JSON.
401authentication_errorMissing, wrong or revoked key.
402invalid_request_errorNo credits left. Top up on the dashboard.
413invalid_request_errorRequest larger than 32 MB.
429rate_limit_errorOver 10 requests per second. Wait for retry-after.
5xxserver_errorOur side. Retry after a moment.
LimitValue
Rate10 requests / second / account, all keys together
Context1M tokens
Output256k tokens
PriceSame token prices as the app. A call smaller than $0.0001 is free.
CreditsSame balance as the app
Something unclear or wrong?Tell us on Discord →