Skip to contentNewKimi K3.1 Pro is now availableTry it now
Docs / Asynchronous inference

Asynchronous inference

Send individual requests to /v1/slow that complete within 24 hours at reduced cost.

The OpenAI-compatible Asynchronous Inference API accepts individual inference requests that complete within 24 hours at reduced cost. Use /v1/slow instead of /v1 in your API calls.

Background inference is cheaper, and easier to build with when your application isn't serving real-time inference.

How it works

The Asynchronous Inference API is a simple way to make cost-effective inference requests when you don't need an immediate response. With the /v1/slow prefix instead of /v1, you:

  1. Get a request ID immediately: your API call returns at once with a unique ID.
  2. Save on cost: pricing is significantly lower than synchronous requests.
  3. Get flexible completion: requests complete within 24 hours.
  4. Use the same API: the request format is the same as the standard endpoints.

Good fits include:

  • Large-scale content generation
  • Batch document processing
  • Non-urgent data analysis
  • Cost-sensitive workloads
  • Background processing tasks

Get started

Change your base URL from /v1/ to /v1/slow/. The API stays fully compatible with the OpenAI SDK, and the same credit-billing API key works for both. Plan keys cannot submit /v1/slow requests or read Group status and results (they return 403 plan_route_not_supported); use a key that bills API credits instead (see plan keys).

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.inference.net/v1/slow", // Note the /v1/slow prefix
  apiKey: process.env.INFERENCE_API_KEY,
});

Make an asynchronous request

Submit a request

Make requests exactly as you would with the standard API. The response includes a request ID instead of the completion result:

const response = await client.chat.completions.create({
  model: "kimi-k3-fast",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "What is the capital of France?" },
  ],
  max_tokens: 1000,
});

console.log(response.id); // Returns immediately with request ID

The initial response includes a unique request ID:

json
{
  "id": "N2mZQjrvh-k_m8nMMN7Jn",
  "choices": [],
  "created": 1749061362809,
  "model": "kimi-k3-fast",
  "object": "chat.completion"
}

Calling from a Cloudflare Worker

Cloudflare allows a request to pass through at most 16 Workers. If your call reaches the API after too many Worker-to-Worker or service-binding hops on your side, the API cannot forward it through Cloudflare Workers. When a route outside Cloudflare Workers is available, the API may send an async or slow POST once by that route instead. Otherwise it returns HTTP 508:

json
{
  "error": {
    "message": "The request reached inference.net through too many Cloudflare Worker hops, so it could not be forwarded. ...",
    "type": "subrequest_depth_exceeded",
    "request_id": "5f0c2a7e-3b1d-4c8e-9a6f-2d4e8b1c7a90"
  }
}

A 508 means no request was created. A retry through the same chain can fail the same way: send the request from a point with fewer Worker hops before it, for example directly from the Worker that receives your traffic. If the API sent the request by the other route and that failed, you get a different 5xx error. That request may have been created, so check for it before you send it again.

Retrieve the result

Once the request is processed, retrieve the result from the generation endpoint.

const response = await fetch(
  `https://api.inference.net/v1/generation/${generationId}`,
  {
    headers: {
      Authorization: `Bearer ${process.env.INFERENCE_API_KEY}`,
    },
  },
);
const result = await response.json();

The completed response includes both the original request and the generation result:

json
{
  "request": {
    "messages": [
      { "content": "You are a helpful assistant.", "role": "system" },
      { "content": "What is the meaning of life?", "role": "user" }
    ],
    "model": "kimi-k3-fast",
    "stream": false,
    "max_tokens": 8,
    "metadata": { "webhook_id": "mPufxRcrw" }
  },
  "response": {
    "id": "N2mZQjrvh-k_m8nMMN7Jn",
    "object": "chat.completion",
    "created": 1749061362,
    "model": "kimi-k3-fast",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "The meaning of life is a complex and",
          "reasoning_content": null,
          "tool_calls": null
        },
        "logprobs": null,
        "finish_reason": "length",
        "matched_stop": null
      }
    ],
    "usage": {
      "prompt_tokens": 48,
      "total_tokens": 56,
      "completion_tokens": 8,
      "prompt_tokens_details": null
    },
    "system_fingerprint": ""
  },
  "state": "Success",
  "stateMessage": "Generation successful",
  "error": null,
  "finishedAt": "2025-06-04T18:22:42.912Z",
  "deadlineAt": null
}

Completion window

By default an asynchronous request completes within 24 hours. To get the result sooner, set metadata.completion_window to how long you can wait, from submission to webhook delivery:

json
{
  "model": "google/gemma-3-27b-instruct/bf-16",
  "messages": [{"role": "user", "content": "What is the capital of France?"}],
  "metadata": {"webhook_id": "mPufxRcrw", "completion_window": "4m"}
}
  • The value is a string: an integer and a unit, ms, s, m, or h (for example "90s", "4m", "24h"), from 60s to 72h.
  • Any other value is ignored: the request is accepted without a window from metadata, as if the field were absent.
  • The submit response, the webhook payload, and the generation status endpoint return the resulting deadline. The submit response has deadline_at (Unix seconds); the generation object has deadlineAt (ISO 8601).
  • A request without metadata.completion_window can still get a deadline from a default set on its endpoint. A request with neither returns no deadline_at and has deadlineAt: null.

A window of 1 hour or less changes how the request is handled:

  1. It is dispatched ahead of requests with a later deadline or none, and queued requests of the same model wait while it waits for capacity.
  2. While the model is busy, its retry wait is capped by the time left: at most 1/16 of what remains of the window, never longer than the normal backoff (up to a minute). A 4-minute window retries about every 5 to 13 seconds.
  3. A failed webhook delivery is retried several times inside the window, then on the normal retry schedule.

A longer window is accepted and returned as the deadline, but is handled like a request without one. A queued request whose deadline has passed settles as Failed (stateMessage: "Inference expired") instead of running. A request actively running at its deadline is not cancelled; however, if an in-progress request loses its worker claim and both its deadline has passed and it has gone at least 15 minutes since its last updatedAt update, reconciliation settles it as Failed (stateMessage: "Inference expired").

Worked example: a 4-minute window

The request is submitted at 0:00 with "completion_window": "4m", so its deadline is 4:00. The model finishes at 0:30, and your endpoint fails until attempt 5. Nominal webhook attempt times (each wait varies by up to 20%):

AttemptTime since submissionWait before it
10:30None
20:355 seconds
31:0530 seconds
4About 2:32About 88 seconds
5About 3:16About 44 seconds
6About 3:38About 22 seconds
7About 3:5315 seconds
8About 4:0815 seconds
9 to 244 hours more each4 hours

Inside the window, each wait is half the time left to the deadline, at least 15 seconds (1/16 of the window), and never longer than the normal schedule's wait for that attempt. After the deadline the normal schedule resumes at the current attempt, so the event still gets 24 attempts in total.

Request states

StatusDescription
QueuedRequest received and queued for processing
In ProgressRequest is currently being processed
SuccessRequest completed successfully, results available
FailedRequest failed due to an error

Best practices

  1. Store request IDs: always save the returned request ID for later retrieval. With ZDR on, retrieval returns purged content once the webhook delivery finishes, so rely on the webhook for the result.
  2. Use webhooks: instead of polling, set up webhooks to be notified when requests complete. See Webhooks.
  3. Handle failures: a 4xx status other than 429 means the request fails again if resent unchanged; a 429 or 5xx status can succeed on retry. Queued requests continue processing after the submitting client disconnects; disconnecting does not cancel asynchronous work.
  4. Batch when possible: for many requests, use the Batch API or the Group API. Batch requests are not available while ZDR is on; group requests need a webhook.

Supported endpoints

  • /v1/slow/chat/completions
  • /v1/slow/completions
  • /v1/slow/embeddings

Replace /v1/ with /v1/slow/ in your existing code to use asynchronous processing.

Pricing and limits

  • Pricing: significantly reduced compared to synchronous requests (contact sales for specific rates)
  • Completion time: 24 hours
  • Rate limits: more generous than synchronous endpoints. See Rate limits.
  • Request expiration: requests expire after 24 hours if not completed

For specific pricing and higher rate limits, contact support@inference.net.