### NeuroAPI Response Example (JSON) Source: https://neuroapi.host/docs/overview/index Illustrates a typical JSON response from NeuroAPI, showing the structure for a chat completion, including the message content, usage statistics, and model identifier. ```json { "id": "chatcmpl-xxxxxxxxxxxxxx", "choices": [ { "finish_reason": "stop", "message": { "role": "assistant", "content": "Hello!" } } ], "usage": { "prompt_tokens": 10, "completion_tokens": 2, "total_tokens": 12 }, "model": "gpt-4o" } ``` -------------------------------- ### Finish Reason Normalization Source: https://neuroapi.host/docs/overview/index Explains the normalized values for the `finish_reason` field across different models and providers. ```APIDOC ## Finish Reason NeuroAPI normalizes the `finish_reason` of each model to one of the following values to provide a consistent experience across different providers: - `tool_calls`: The model stopped because it intended to call a tool. - `stop`: The model stopped because it reached a natural stopping point. - `length`: The model stopped because it reached the maximum token limit. - `content_filter`: The model stopped due to a content filter. - `function_call`: The model stopped because it intended to call a function (used for legacy function calling). Note: Some models or providers might have additional, specific finish reasons. The original `finish_reason` string returned by the model is accessible via the `native_finish_reason` property if needed. ``` -------------------------------- ### Token Counting Source: https://neuroapi.host/docs/overview/index Details how tokens are counted for requests, covering both text and image data. ```APIDOC ## Token Counting The system counts tokens before processing a request to estimate costs and enforce limits. This count includes tokens from message content and any tools used. ### Text Data Tokenization - A tokenizer compatible with OpenAI models is used for text content. - The token count includes tokens from message roles (e.g., 'user', 'assistant') and the content of each message. - Tokens from function descriptions provided in the `tools` parameter are also included in the count. ### Image Data Tokenization - The token cost for processing images depends on their size and the `detail` parameter within the `image_url` object. - **`detail: 'low'`**: The image is processed at a lower resolution, incurring a fixed and lower token cost. - **`detail: 'high'`**: The image is processed at a higher resolution. It is scaled and then divided into 512x512 pixel tiles. The final token cost is determined by the number of these tiles. ``` -------------------------------- ### NeuroAPI Response Schema (TypeScript) Source: https://neuroapi.host/docs/overview/index Defines the structure of the response from NeuroAPI, normalizing it to match the OpenAI Chat API. Includes types for non-streaming and streaming choices, usage data, and error information. ```typescript type Response = { id: string; choices: (NonStreamingChoice | StreamingChoice)[]; created: number; model: string; object: 'chat.completion' | 'chat.completion.chunk'; system_fingerprint?: string; usage?: ResponseUsage; }; type ResponseUsage = { prompt_tokens: number; completion_tokens: number; total_tokens: number; }; type NonStreamingChoice = { finish_reason: string | null; message: { content: string | null; role: string; tool_calls?: ToolCall[]; }; error?: ErrorResponse; }; type StreamingChoice = { finish_reason: string | null; delta: { content: string | null; role?: string; tool_calls?: ToolCall[]; }; error?: ErrorResponse; }; type ErrorResponse = { code: number; message: string; metadata?: Record; }; type ToolCall = { id: string; type: 'function'; function: { name: string; arguments: string; }; }; ``` -------------------------------- ### Chat Completion Response Schema Source: https://neuroapi.host/docs/overview/index Defines the structure of the response received from the chat completion endpoint, including details for both streaming and non-streaming outputs. ```APIDOC ## Chat Completion Response Schema This schema describes the structure of the response from the chat completion endpoint. It is designed to be compatible with the OpenAI Chat API. ### Response Structure - **id** (string): Unique chat identifier. - **choices** (Array): An array containing the generated choices. The structure differs based on the `stream` parameter. - **created** (number): Unix timestamp (in seconds) of chat creation. - **model** (string): The model used for generation (e.g., "gpt-4o", "claude-3-sonnet"). - **object** (string): Type of the object, either 'chat.completion' or 'chat.completion.chunk'. - **system_fingerprint** (string, optional): A unique identifier for the internal backend configuration used. - **usage** (ResponseUsage, optional): Token usage data for the request. Sent in the last message when streaming. ### Response Usage - **prompt_tokens** (number): Number of tokens in the prompt. - **completion_tokens** (number): Number of tokens in the generated response. - **total_tokens** (number): Total number of tokens in the request and response. ### Non-Streaming Choice - **finish_reason** (string | null): The reason the model stopped generating tokens ('stop', 'length', 'tool_calls', 'content_filter'). - **message** (object): - **content** (string | null): The generated message content. - **role** (string): Author's role ('assistant'). - **tool_calls** (Array, optional): Tools called by the model. - **error** (ErrorResponse, optional): Error information, if any occurred. ### Streaming Choice - **finish_reason** (string | null): The reason the model stopped generating tokens. Appears only in the last chunk. - **delta** (object): - **content** (string | null): Part of the message content. - **role** (string, optional): Author's role (usually in the first fragment). - **tool_calls** (Array, optional): Tools called by the model (appear in parts). - **error** (ErrorResponse, optional): Error information, if any occurred. ### Error Response - **code** (number): Error code. - **message** (string): Error message. - **metadata** (Record, optional): Additional metadata about the error. ### Tool Call - **id** (string): Tool call ID. - **type** (string): Tool type ('function'). - **function** (object): - **name** (string): Function name. - **arguments** (string): Function arguments as a JSON string. ### Response Example ```json { "id": "chatcmpl-xxxxxxxxxxxxxx", "choices": [ { "finish_reason": "stop", "message": { "role": "assistant", "content": "Hello!" } } ], "usage": { "prompt_tokens": 10, "completion_tokens": 2, "total_tokens": 12 }, "model": "gpt-4o" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.