Documentation

Quickstart and API reference

Authenticate, deploy a model to a GPU pool, and send a request. The same API serves every model format, so the call shape does not change when you move from a 3B reranker to a 34B vision model.

Quickstart

Three steps to a first token.

The API base URL and host for your project are shown in the console under project settings.

You need a project, an API key with the invoke and deploy scopes, and a model artifact or container image. The examples use NEURAFLOW_URL for the API base and NEURAFLOW_KEY for the bearer token.

shellenvironment
export NEURAFLOW_URL="$NEURAFLOW_URL"
export NEURAFLOW_KEY="nf_live_7Qc2...4mZ"
01 / Authenticate

One header, scoped keys, no cookies.

Send the key as a bearer token on every request. Keys are scoped to one project and one of three roles: invoke can call endpoints, deploy can create and update endpoints, and admin can manage keys and spend caps. Create separate keys for each service so a leak has a narrow blast radius.

httprequest headers
POST /v1/chat/completions HTTP/1.1
Host: $NEURAFLOW_HOST
Authorization: Bearer nf_live_7Qc2...4mZ
Content-Type: application/json
Idempotency-Key: rank-2026-11-24-000418

{"model":"reranker-3b","messages":[{"role":"user","content":"score this query"}]}

Keys are shown once at creation. Store them in a secret manager; do not put them in client-side code or in URLs. A key can be revoked immediately, and the edge cache rejects it within 30 seconds.

02 / Deploy a model

Point at an artifact or a container.

The deployment API accepts either a registry artifact or a container image. Artifacts are identified by a model name and a content digest; the service resolves the format from the manifest. The response returns an endpoint ID that stays stable across restarts and rollouts.

shellcreate endpoint
curl -sS -X POST "$NEURAFLOW_URL/v1/endpoints" \
  -H "Authorization: Bearer $NEURAFLOW_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "rank-prod",
    "model": "reranker-3b",
    "format": "safetensors",
    "gpu_class": "24gb",
    "regions": ["fra-1", "iad-1"],
    "min_replicas": 2,
    "max_replicas": 14,
    "scale_to_zero": false
  }'
json202 accepted
{
  "id": "ep_01J8R3K2",
  "name": "rank-prod",
  "status": "provisioning",
  "url": "$NEURAFLOW_URL/e/rank-prod",
  "replicas": {"desired": 2, "ready": 0},
  "created_at": "2026-11-24T09:14:02Z"
}

For a custom container, replace the model fields with "image": "registry.neuraflow.internal/ranker:2.4" and expose /health and /generate. The runtime injects MODEL_PATH and PORT.

03 / Call the endpoint

The endpoint URL is stable; the pool behind it is not.

Send inference requests to the endpoint URL with the same bearer token. The router selects a replica in the closest healthy region. Response headers include the region, queue wait, and replica ID so a client can log the decision without parsing the body.

pythonchat completion
import json
import os
import requests

url = os.environ["NEURAFLOW_URL"] + "/e/rank-prod/v1/chat/completions"
headers = {
    "Authorization": f"Bearer {os.environ['NEURAFLOW_KEY']}",
    "Content-Type": "application/json",
}
body = {
    "model": "reranker-3b",
    "messages": [{"role": "user", "content": "Score these candidates."}],
    "max_tokens": 64,
    "temperature": 0.0,
}

response = requests.post(url, headers=headers, json=body, timeout=2.0)
response.raise_for_status()
data = response.json()

print(data["choices"][0]["message"]["content"])
print(response.headers["x-neuraflow-region"], response.headers["x-neuraflow-queue-ms"])
04 / Streaming

Server-sent events, one JSON object per token.

Set "stream": true to receive a text/event-stream response. Each event is a JSON object with a delta and, on the final event, a usage block. The stream ends with data: [DONE]. A client disconnect cancels the generation at the next token boundary.

pythonstream reader
import json
import os
import requests

url = os.environ["NEURAFLOW_URL"] + "/e/rank-prod/v1/chat/completions"
body = {
    "model": "reranker-3b",
    "messages": [{"role": "user", "content": "List three failure modes."}],
    "stream": True,
}

with requests.post(url, json=body, stream=True, timeout=(2, 30),
                    headers={"Authorization": f"Bearer {os.environ['NEURAFLOW_KEY']}"}) as r:
    r.raise_for_status()
    for line in r.iter_lines():
        if not line or not line.startswith(b"data: "):
            continue
        chunk = line[6:]
        if chunk == b"[DONE]":
            break
        event = json.loads(chunk)
        print(event["choices"][0]["delta"].get("content", ""), end="")
05 / Endpoint reference

Six endpoints cover deployment and inference.

All paths are relative to your project base URL, $NEURAFLOW_URL. Inference paths are also reachable under an endpoint prefix: /e/{endpoint}/v1/chat/completions. JSON bodies use UTF-8, and unknown fields are rejected with 422.

MethodPathPurposeScope
POST /v1/chat/completions Chat-shaped generation, streaming or single JSON response. invoke
POST /v1/completions Plain text completion with the same batching and usage accounting. invoke
POST /v1/embeddings Returns normalized vectors; accepts up to 256 inputs per call. invoke
POST /v1/rerank Scores documents against a query and returns the top N in order. invoke
POST /v1/endpoints Creates or updates an endpoint from an artifact or container image. deploy
GET /v1/endpoints/{id} Returns rollout status, replica counts, region health, and the current digest. deploy

Common fields

  • model — artifact name or endpoint model alias. Required on every inference call.
  • max_tokens — output cap, 1 to 8,192. The default is 256.
  • temperature — 0.0 to 2.0. At 0.0 the runtime uses greedy decoding.
  • stream — boolean. Streaming is enabled by default for chat and completion routes.
  • Idempotency-Key — optional header, retained for 24 hours. Repeated keys return the original response.
06 / Error codes

Failures carry a stable code and a request ID.

Every error body includes error.code, error.message, and error.request_id. Use the request ID when contacting support; it maps to the edge decision, queue wait, and replica trace.

StatusCodeMeaningClient action
400invalid_jsonBody is not valid JSON or violates the schema.Fix the body; do not retry.
401invalid_keyMissing, malformed, or revoked bearer token.Refresh the key; do not retry blindly.
402spend_capProject or key spend cap has been reached.Raise the cap in the console.
403scope_deniedKey lacks the required scope for this route.Use a key with the right role.
404endpoint_missingEndpoint name or model alias does not exist in the project.Check the deployment status.
409rollout_conflictA rollout is already changing that endpoint.Wait for the current rollout to finish.
422invalid_fieldA known field has a value outside its allowed range.Correct the field; do not retry.
429queue_fullAdmission refused because the projected wait exceeds the policy.Honor Retry-After or shed load.
500runtime_errorThe model process failed after admission.Retry once, then alert.
503no_capacityNo healthy replica is available in any allowed region.Retry once after Retry-After.
504deadlineThe request exceeded the endpoint deadline.Reduce max tokens or loosen the deadline.
07 / Limits

Defaults that can be raised with a support request.

LimitDefaultNotes
Request body1 MBLarger bodies are rejected at the edge with 413.
Maximum tokens per request8,192 outputInput context depends on the model artifact.
Batch tokens per replica8,192Configurable per endpoint policy.
Queue depth200 requestsAdmission also enforces a 60-second projected wait.
Stream duration5 minutesA 15-second idle timeout applies to voice workloads.
Embedding inputs256 per callEach input up to 8,192 tokens.
Trace retention30 daysHourly metric rollups remain for 13 months.
Default request rate300 req/s per keyBursts above the limit receive 429.
Versioning. The /v1 path is stable. Additive response fields may appear without notice; clients should ignore unknown fields. Removing a field or changing a status code requires a new path version.