Skip to content

OpenAIResponse

Defined in: frontend/dist/types/adapters/openai.d.ts:150

OpenAI Chat Completions API response structure.

Contains the complete response from OpenAI’s API including the generated message, finish reason, and token usage statistics.

const response: OpenAIResponse = {
id: 'chatcmpl-123',
object: 'chat.completion',
created: 1677652288,
model: 'gpt-4',
choices: [{
index: 0,
message: {
role: 'assistant',
content: 'Hello! How can I help you today?'
},
finish_reason: 'stop'
}],
usage: {
prompt_tokens: 9,
completion_tokens: 12,
total_tokens: 21
}
};

choices: object[]

Defined in: frontend/dist/types/adapters/openai.d.ts:160

Array of completion choices (usually just one)

finish_reason: "length" | "stop" | "tool_calls" | "content_filter" | null

Reason why generation stopped: ‘stop’ (natural), ‘length’ (max tokens), ‘tool_calls’, ‘content_filter’, or null

index: number

Choice index in the array

message: OpenAIMessage

Generated message from the assistant


created: number

Defined in: frontend/dist/types/adapters/openai.d.ts:156

Unix timestamp when the response was created


id: string

Defined in: frontend/dist/types/adapters/openai.d.ts:152

Unique identifier for this completion


model: string

Defined in: frontend/dist/types/adapters/openai.d.ts:158

Model used for generating the response


object: "chat.completion"

Defined in: frontend/dist/types/adapters/openai.d.ts:154

Object type - always ‘chat.completion’ for non-streaming


optional usage: object

Defined in: frontend/dist/types/adapters/openai.d.ts:169

Token usage statistics for billing and monitoring

completion_tokens: number

Number of tokens in the completion

prompt_tokens: number

Number of tokens in the prompt

total_tokens: number

Total tokens used (prompt + completion)