Skip to content
Copy a prompt for your AI tool. Keep your key local.
PALEPALE / DOCUMENTATION

API reference

Account access, streaming, spending caps, usage and payments.

Credentials and setup

Use https://api.palepale.tech/v1 as your SDK base URL. Send credentials in the Authorization: Bearer … header. Disable automatic SDK retries because an interrupted request can still be billable.

  1. Create an account or call POST /v1/accounts. Save the po_ owner credential when it appears. It manages the account.
  2. Create an inference key in Your account or send the owner credential to POST /v1/account/keys with {"label":"my-app"}. Save the returned pk_ key when it appears and use it for model requests. To connect Palepale CLI, run palepale login.
  3. Fund the wallet through Billing when payments are available. Account creation starts with an empty wallet.

Keep keys out of source, frontend bundles and AI chats. Legacy 16-digit credentials are unsupported.

Models and completions

Get an available model ID from GET /v1/models and send it to POST /v1/chat/completions with your inference key. GET /v1/models returns {"object":"list","data":[...]}. Use GET /v1/models/{id} for a single model or HTTP 404 for an unknown ID. Both responses use Cache-Control: no-store.

Replace the model in this request body with an available ID.

json
{  "model": "REPLACE_WITH_AVAILABLE_MODEL_ID",  "messages": [{ "role": "user", "content": "Hello" }],  "max_tokens": 128,  "stream": true,  "stream_options": { "include_usage": true }}

Send either max_tokens or max_completion_tokens. Check the route's context_window, max_output_tokens and default_max_output_tokens. Output includes reasoning and tool arguments. Completions have a 30-minute deadline and non-streaming results have an 8 MiB limit. Stream large outputs. A length finish means generation hit its output limit. Discard incomplete tool calls.

Read capabilities for supported options. Older clients may read input_modalities and reasoning_efforts at the model's top level.

  • Send image_url message parts when input_modalities includes image.
  • Enable prompt_cache_key only with prompt_caching. Cache hits are best effort.
  • Enable web_search_options with web_search. Use search separately from function tools.
  • Run function tools in your app. Return each result with its matching tool_call_id. Use parallel_tool_calls only when the model advertises it. Named selection requires named_tool_choice and a matching declaration in tools. Use auto or none when required_tool_choice is false.
  • Choose reasoning_effort and response_format from the advertised values. Check top_p before sending it. For json_schema, use a 1–64 character name of letters, digits, underscores or hyphens. The schema allows 16 levels and 2,048 nodes.
  • When reasoning_content is advertised, set include_reasoning:false to hide reasoning text. Reasoning tokens still count as output.

For SSE, assemble choices[].delta.content and indexed tool-call fragments from data: frames. Comments keep the stream alive. Read the finish reason and, when requested, final usage in the frame with empty choices. Cached tokens are already in prompt tokens and reasoning tokens are already in completion tokens.

Check for a typed error before data: [DONE], even after HTTP 200. A disconnect may cut off the final frames. Check Usage for the confirmed charge.

An optional Idempotency-Key takes 1–128 letters, digits, periods, underscores, colons or hyphens. Use one key per intended completion. Reusing it within the account returns 409 with the original reference, even if the body changes. That request neither dispatches again nor replays content. Each unkeyed request is independent. Save the accepted response's X-Request-Id for billing or support.

Context and input usage

Completion requests allow 32 MiB of JSON. Larger requests return HTTP 413. Messages, personal instructions, schemas and attachments count toward context admission. Leave room for output. On a context_budget response, reduce context or choose a larger model before sending again. Unknown or unsupported fields return a request error. The legacy agent_profile label is ignored.

Send a completion body up to 256 KiB and an inference key to POST /v1/chat/completions/count_tokens. It returns input_tokens, method, input_allowance, context_window, output_budget and fits. A fits:null result means the request could not be fully estimated, including some image or search requests. Supplier estimates require available credit. Counting does not dispatch inference or charge your wallet. Use Usage for final counts and charges.

The catalog publishes exact decimal USD per million tokens in input_per_1m_usd, cached_input_per_1m_usd and output_per_1m_usd. presentation carries display information. Use the advertised capabilities and availability for admission. billing.rounding: receipt_then_ceiling rounds the confirmed charge up to a microdollar. minimum_charge_usd and charge_increment_usd describe the customer charge.

If cache_write_per_1m_usd is present, five-minute cache writes have a separate rate. Subtract cached_tokens and cache_creation_tokens in usage.prompt_tokens_details from total prompt tokens to get ordinary input. One-hour cache writes are unsupported.

GET /v1/agent-profiles?model=MODEL_ID lists profiles available to that model. An empty list means no profile is available.

Errors

Errors return error.type, error.code, error.message and error.retry. A safe reference may be present. Use X-Request-Id for support.

HTTP statusMeaning
400Invalid or unsupported request
401Missing, invalid, revoked or wrong-role credential
402Insufficient credit or a spending limit
404Unknown resource or unsupported endpoint
409Conflict, pending usage or invalid payment evidence
413Request body too large
429Capacity limit or polling too fast
500Unexpected failure
503Route, quota, dependency or payment processing unavailable

capacity_limited and slow_down return Retry-After: 5 before dispatch. Unavailable reads may return retry:true. Retry those reads with bounded backoff. Completion failures after submission, SSE errors and quota exhaustion use retry:false. Check Usage before repeating an ambiguous inference request. Share the error code, model, request or payment ID, time and timezone with support.

Wallet and usage

Use an owner credential for these routes.

RouteResponse
GET /v1/accountAccount id
GET /v1/account/keysIDs, labels, revocation and creation metadata
DELETE /v1/account/keys/{id}204 after revocation
GET /v1/account/walletbalance, held and available in microdollars
GET /v1/account/usageRequest accounting and pending states

Wallet amounts are integer strings. One dollar equals 1,000,000 microdollars. Available credit equals balance minus held. Pending inference does not reserve wallet credit, and null charges or counts mean usage is still unknown.

Usage returns up to 100 rows, newest first. Use before with an exclusive createdAt timestamp. For complete pagination across tied timestamps, use the usage log below.

Usage and payment reports

GET /v1/account/usage/report?days=30 accepts an owner credential, browser session or inference key. It returns window, totals, models and a zero-filled daily series for the same account. Settled or reconciled requests contribute spend and token counts. Pending and unknown requests count separately.

days covers 1–366 UTC calendar days, including today. Use 0 for all-time totals and model aggregates with the latest 366 daily rows. series_from shows where that series starts. The older GET /v1/account/usage/summary?days=30 uses a rolling window. An inference key can also read GET /v1/account/summary. Key management and top-ups require management credentials.

With an owner credential or browser session, use GET /v1/account/usage/log and GET /v1/account/payments. They accept days, limit (1–100, default 50) and cursor. They return {data, totals, next_cursor, window}. Pass next_cursor unchanged. It preserves the first page cutoff and uses full timestamps and IDs to handle ties. Totals cover the whole window. Pending records may settle between page requests.

Payment records show invoice state, requested credit, confirmed gross credits and sandbox status. Refunds are separate. Reports use decimal strings for amounts and counters and omit conversation content.

OxaPay top-ups

Use Billing or check GET /v1/funding for enabled payment options, the processor, minimum and maximum, cent increments, payer fees and sandbox status. Disabled payments show enabled:false and sandbox:null.

Send POST /v1/account/top-ups with an owner credential or browser session, a stable Idempotency-Key and a body such as {"amount":"5.00"}. Use decimal USD from 1.00 to 1000.00. A new invoice returns 201. The same key and amount returns 200 with the existing invoice. Changed terms conflict.

Save the key and amount before sending. After a lost response, use them again while payments are enabled. Use GET /v1/account/top-ups/{id} to read a known invoice even when new purchases are disabled. The account page saves the retry details in its current tab.

Pay through the invoice's validated checkout link and check Billing for confirmed credit. Pending invoices can have a null checkout. Fees and sandbox payments do not add production credit. Contact support about refunds or an existing QRIS payment. Payment recovery.

Spending caps and run budgets

GET /v1/account/spending-limits returns your lifetime paid cap, confirmed spend and a compatibility reserved field set to zero. With an owner credential or browser session, send PUT /v1/account/spending-limits with a body such as {"amount":"10.00"} or use PUT /v1/account/keys/{id}/spending-limit for one key. Send amount:null to remove a cap. Existing confirmed spend counts. Both caps apply, and already authorized work may finish.

With an inference key, send POST /v1/account/run-budgets with {"amount":"2.00"}. Attach the returned id as budget_id on paid completions for the same key. Run budgets last 24 hours and track confirmed spend. An expired or exhausted budget returns HTTP 402 budget_exceeded before generation. Account and key caps still apply when requests omit budget_id. Trial funding is separate.

Use positive USD limits up to 1000000.00 with up to two decimal places. A key can have up to 100 unexpired run budgets. palepale --budget 2.00 starts a budget for one CLI run. Changing credentials requires a new run. Use --budget separately from --trial.

Browser account access

Use Sign in to open Your account and Pair a device to approve CLI access. The browser sends the owner credential during sign-in and keeps it out of browser storage.

POST /v1/account/sessions exchanges an owner credential for {id, token, ttl, createdAt, expiresAt}. A ps_ session lasts eight hours, or 30 days with remember:true. Use it for account management. Inference uses a separate key.

RouteAction
GET /v1/account/sessionRead the current session
GET /v1/account/sessionsList active sessions
DELETE /v1/account/sessions/{id}Revoke a session

Expiry, owner revocation and account disablement block later authentication. Already authorized requests may still finish. Revoking a browser session, including sign-out, also revokes its linked chat keys. Manage independently paired CLI keys in Devices.

Device pairing

  1. Send optional hostname and client to POST /v1/pair/start. Keep the returned device_code on the requesting device. Display user_code for approval. The response includes ttl of 900 seconds and interval of five seconds.
  2. With an owner credential or browser session, send {"user_code":"..."} to POST /v1/pair/inspect to check the device label and expiry. Match the code to the terminal before calling POST /v1/pair/approve with the same body. Add "deny":true to reject. The requesting device provides its own label.
  3. Poll POST /v1/pair/poll with {"device_code":"..."} every five seconds. Pending approval returns 202. Polling sooner returns 429 with Retry-After: 5. Successful collection checks the approving account and owner credential and returns {"status":"ready","api_key":"pk_..."} once. Expired, denied and consumed pairings return 410.

Pairing responses use Cache-Control: no-store. If the collection response is lost, start a new pairing and revoke the unused key.

Account discovery aliases

The read-only routes below use Palepale Bearer credentials, response shapes and documented query parameters.

AliasProjectionCredentials
GET /api/meWallet snapshot, all-time usage totals, site/api origins, wallet statusOwner, browser session or inference
GET /api/me/usageSame as /v1/account/usage/reportOwner, browser session or inference
GET /api/me/usage/logSame as /v1/account/usage/logOwner or browser session
GET /api/me/paymentsSame as /v1/account/paymentsOwner or browser session
GET /api/me/keysSame as /v1/account/keysOwner or browser session

All responses use Cache-Control: no-store. Counters and microdollar amounts remain exact decimal strings. Usage/payment aliases retain canonical days/limit/cursor semantics. /api/me and /api/me/keys accept no query parameters. Unknown or repeated query parameters are rejected. Wallet amounts and totals can change as requests finish. can_spend reflects permitted wallet credit; model availability and account limits still apply.

The configured public origins appear in the response. Use the canonical /v1 routes for new integrations.

Balance snapshots on JSON completions

A successful non-streaming response may include X-Balance-Microdollars, X-Available-Microdollars and X-Reserved-Microdollars. These optional integer headers describe the wallet just after generation. Refunds and other requests can change the balance. Use Usage for settled charges. Streams send response headers before generation completes.

Browser chat

Chat uses a separate inference key bound to the browser session. POST /v1/account/keys accepts session_bound:true with a browser session. The website keeps the key in an HttpOnly cookie. Session expiry, session revocation or owner revocation disables the key.

Chat uses the live catalog and streams replies. Stop cancels the stream, and incurred usage can still settle. Request history includes funding, hold_since and recovery_status (none, running, checking_charge or needs_review). reserved_microdollars is zero for inference.

Saved web chats sync across signed-in devices. Export or delete each chat from your account. Browser-only history uploads only on request. CLI and API conversations stay outside web history.

OpenCode V2 and Palepale CLI

Run palepale opencode to connect an installed OpenCode V2 client. The command pairs if needed, backs up your JSON or JSONC config, merges the public catalog and refresh plugin, and saves an inference key privately. It keeps existing providers and preserves original comments in the backup. Upgrade a V1 client before connecting. OpenCode setup.

HY4 free usage

A confirmed paid wallet top-up unlocks $2 of HY4 usage once per account. Web, CLI and API share that allowance.

Select hy4 and check your remaining allowance in Chat or Billing. HY4 uses its own allowance and stops when it cannot cover a request. Model availability and request limits still apply.

GET /v1/account/model-benefits shows eligibility and the used, pending and remaining amounts in microdollars. HY4 catalog rates measure how much of the $2 allowance each request uses.

Need a hand?

Open Palepale Discord for account support. Compare model rates or read about wallet billing.

REQUEST EXAMPLES

Make your first request.
Use your own access details.

Set your local key and catalog model ID. These examples need streaming support.

Get API access
first-request.sh
# Set PALEPALE_API_KEY locally; choose a catalog ID with streaming enabled.curl -N "https://api.palepale.tech/v1/chat/completions" \  -H "Authorization: Bearer $PALEPALE_API_KEY" \  -H "Content-Type: application/json" \  -d "{\"model\":\"$PALEPALE_MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello\"}],\"stream\":true,\"stream_options\":{\"include_usage\":true}}"