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.
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.
export NEURAFLOW_URL="$NEURAFLOW_URL" export NEURAFLOW_KEY="nf_live_7Qc2...4mZ"
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.
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.
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.
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 }'
{
"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.
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.
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"])
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.
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="")
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.
| Method | Path | Purpose | Scope |
|---|---|---|---|
| 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.
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.
| Status | Code | Meaning | Client action |
|---|---|---|---|
| 400 | invalid_json | Body is not valid JSON or violates the schema. | Fix the body; do not retry. |
| 401 | invalid_key | Missing, malformed, or revoked bearer token. | Refresh the key; do not retry blindly. |
| 402 | spend_cap | Project or key spend cap has been reached. | Raise the cap in the console. |
| 403 | scope_denied | Key lacks the required scope for this route. | Use a key with the right role. |
| 404 | endpoint_missing | Endpoint name or model alias does not exist in the project. | Check the deployment status. |
| 409 | rollout_conflict | A rollout is already changing that endpoint. | Wait for the current rollout to finish. |
| 422 | invalid_field | A known field has a value outside its allowed range. | Correct the field; do not retry. |
| 429 | queue_full | Admission refused because the projected wait exceeds the policy. | Honor Retry-After or shed load. |
| 500 | runtime_error | The model process failed after admission. | Retry once, then alert. |
| 503 | no_capacity | No healthy replica is available in any allowed region. | Retry once after Retry-After. |
| 504 | deadline | The request exceeded the endpoint deadline. | Reduce max tokens or loosen the deadline. |
Defaults that can be raised with a support request.
| Limit | Default | Notes |
|---|---|---|
| Request body | 1 MB | Larger bodies are rejected at the edge with 413. |
| Maximum tokens per request | 8,192 output | Input context depends on the model artifact. |
| Batch tokens per replica | 8,192 | Configurable per endpoint policy. |
| Queue depth | 200 requests | Admission also enforces a 60-second projected wait. |
| Stream duration | 5 minutes | A 15-second idle timeout applies to voice workloads. |
| Embedding inputs | 256 per call | Each input up to 8,192 tokens. |
| Trace retention | 30 days | Hourly metric rollups remain for 13 months. |
| Default request rate | 300 req/s per key | Bursts above the limit receive 429. |