ChatStreamChunk - TypeScript SDK
ChatStreamChunk - TypeScript SDK
ChatStreamChunk type definition
The TypeScript SDK and docs are currently in beta. Report issues on GitHub.
Streaming chat completion chunk
Example Usage
1 import { ChatStreamChunk } from "@openrouter/sdk/models"; 2 3 let value: ChatStreamChunk = { 4 choices: [ 5 { 6 delta: {}, 7 finishReason: null, 8 index: 0, 9 }, 10 ], 11 created: 1677652288, 12 id: "chatcmpl-123", 13 model: "openai/gpt-4", 14 object: "chat.completion.chunk", 15 };
Fields
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
choices | models.ChatStreamChoice[] | ✔️ | List of streaming chunk choices | |
created | number | ✔️ | Unix timestamp of creation | 1677652288 |
error | models.ErrorT | ➖ | Error information | {"code": 429,"message": "Rate limit exceeded"} |
id | string | ✔️ | Unique chunk identifier | chatcmpl-123 |
model | string | ✔️ | Model used for completion | openai/gpt-4 |
object | models.ChatStreamChunkObject | ✔️ | N/A | |
openrouterMetadata | models.OpenRouterMetadata | ➖ | N/A | {"attempt": 1,"endpoints": {"available": [{"model": "openai/gpt-4o","provider": "OpenAI","selected": true}], “total”: 1<br />},“is_byok”: false, “region”: “iad”, “requested”: “openai/gpt-4o”, “strategy”: “direct”, “summary”: “available=1, selected=OpenAI” } |
serviceTier | string | ➖ | The service tier used by the upstream provider for this request | default |
systemFingerprint | string | ➖ | System fingerprint | fp_44709d6fcb |
usage | models.ChatUsage | ➖ | Token usage statistics | {"completion_tokens": 15,"completion_tokens_details": {"reasoning_tokens": 5},“cost”: 0.0012, “cost_details”: {"upstream_inference_completions_cost": 0.0004,"upstream_inference_cost": null,"upstream_inference_prompt_cost": 0.0008},“is_byok”: false, “prompt_tokens”: 10, “prompt_tokens_details”: {"cached_tokens": 2},“total_tokens”: 25<br />} |