OpenAI Chat Completion
OpenAI Chat Completion response with choices, messages, tool calls, and usage.
openai
Install
$ npx shadcn@latest add @open-types/openai-chat-completion
Dependencies
Source
import type { OpenAIUsage } from "./openai-shared";
export type OpenAIChatMessageRole = "system" | "user" | "assistant" | "tool";
export interface OpenAIToolCallFunction {
name: string;
arguments: string;
}
export interface OpenAIToolCall {
id: string;
type: "function";
function: OpenAIToolCallFunction;
}
export interface OpenAIChatMessage {
role: OpenAIChatMessageRole;
content: string | null;
name?: string;
tool_calls?: OpenAIToolCall[];
}
export type OpenAIFinishReason =
| "stop"
| "length"
| "tool_calls"
| "content_filter";
export interface OpenAIChatCompletionChoice {
index: number;
message: OpenAIChatMessage;
finish_reason: OpenAIFinishReason | null;
}
export interface OpenAIChatCompletion {
id: string;
object: "chat.completion";
created: number;
model: string;
choices: OpenAIChatCompletionChoice[];
usage: OpenAIUsage;
system_fingerprint: string | null;
}
import type { OpenAIUsage } from "./openai-shared";
export type OpenAIChatMessageRole = "system" | "user" | "assistant" | "tool";
export interface OpenAIToolCallFunction {
name: string;
arguments: string;
}
export interface OpenAIToolCall {
id: string;
type: "function";
function: OpenAIToolCallFunction;
}
export interface OpenAIChatMessage {
role: OpenAIChatMessageRole;
content: string | null;
name?: string;
tool_calls?: OpenAIToolCall[];
}
export type OpenAIFinishReason =
| "stop"
| "length"
| "tool_calls"
| "content_filter";
export interface OpenAIChatCompletionChoice {
index: number;
message: OpenAIChatMessage;
finish_reason: OpenAIFinishReason | null;
}
export interface OpenAIChatCompletion {
id: string;
object: "chat.completion";
created: number;
model: string;
choices: OpenAIChatCompletionChoice[];
usage: OpenAIUsage;
system_fingerprint: string | null;
}