POST
/v1/complete
Generate code or text completions from a prompt in a single request.
POST https://api.nascentist.ai/v1/completeRequest
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| prompt | string | Yes | — | The code or text to complete. Include surrounding context for best results. |
| model | string | No | nascentist-1 | Model ID to use. |
| max_tokens | integer | No | 500 | Max tokens to generate. Range: 1–8000 (plan-dependent). |
| temperature | float | No | 0.2 | Sampling temperature. 0 = deterministic, 1 = creative. For code, 0.1–0.3 is recommended. |
| stop | string[] | No | null | Up to 4 stop sequences. |
| stream | boolean | No | false | If true, returns an SSE stream. |
| language | string | No | null | Language hint for better results: "python", "javascript", "typescript", "go", "rust", "java", "cpp". |
| system | string | No | null | System-level instruction prepended to the prompt. |
Request Examples
9 lines
curl -X POST https://api.nascentist.ai/v1/complete \
-H "Authorization: Bearer nsc_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "def binary_search(arr, target):",
"max_tokens": 300,
"temperature": 0.1,
"language": "python"
}'Response
14 lines
{
"id": "cmpl_01ABC123def456",
"object": "completion",
"model": "nascentist-1",
"content": " left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return -1",
"finish_reason": "stop",
"usage": {
"prompt_tokens": 14,
"completion_tokens": 68,
"total_tokens": 82
},
"latency_ms": 734,
"created_at": "2026-03-01T04:18:00Z"
}| Field | Description |
|---|---|
| id | Unique completion identifier. |
| object | Response object type. |
| content | Generated completion text. |
| finish_reason | Why generation stopped (stop, length, etc.). |
| usage | Prompt/completion/total token usage. |
| latency_ms | Server-side response latency in milliseconds. |
Streaming
Set stream: true to receive Server-Sent Events chunks. Each chunk includes incremental text in delta.
5 lines
data: {"delta": " left, "}
data: {"delta": "right = 0, "}
data: [DONE]Errors
Common completion errors
Use the Error Reference for all error objects. Common errors here are
authentication_error, invalid_request_error, and rate_limit_error.