Chat Types TypeScript types for OpenAI-compatible chat completions, including messages, tools, and streaming.
OpenAI Compatibility: The Skytells Chat API implements the OpenAI Chat Completions specification. These TypeScript types mirror the OpenAI API exactly for maximum compatibility. See POST /v1/chat/completions for Skytells-specific details.
See Chat for usage.
type ChatCompletionMessageParam =
| ChatCompletionSystemMessageParam
| ChatCompletionUserMessageParam
| ChatCompletionAssistantMessageParam
| ChatCompletionToolMessageParam
| ChatCompletionFunctionMessageParam // deprecated
Union of all message role types.
interface ChatCompletionSystemMessageParam {
role : 'system' ;
content : string ;
name ?: string ;
}
Field Type Description role'system'Always 'system'. contentstringSystem instruction. namestringOptional participant name.
interface ChatCompletionUserMessageParam {
role : 'user' ;
content : string | ContentPart [];
name ?: string ;
}
Field Type Description role'user'Always 'user'. contentstring | ContentPart[]Text or multi-part (text + image). See Vision . namestringOptional participant name.
interface ChatCompletionAssistantMessageParam {
role : 'assistant' ;
content : string | null ;
name ?: string ;
refusal ?: string | null ;
tool_calls ?: ChatCompletionMessageToolCall [];
}
Field Type Description role'assistant'Always 'assistant'. contentstring | nullReply content. namestringOptional name. refusalstring | nullRefusal message. tool_callsChatCompletionMessageToolCall[]Tool calls. See Tool Calling .
interface ChatCompletionToolMessageParam {
role : 'tool' ;
content : string ;
tool_call_id : string ;
}
Field Type Description role'tool'Always 'tool'. contentstringTool result (JSON string). tool_call_idstringID from the tool call.
interface ChatCompletionTool {
type : 'function' ;
function : {
name : string ;
description ?: string ;
parameters ?: Record < string , any >; // JSON Schema
strict ?: boolean ;
};
}
Field Type Description type'function'Always 'function'. function.namestringFunction name. function.descriptionstringFunction description. function.parametersRecord<string, any>JSON Schema for parameters. function.strictbooleanStrict schema enforcement.
type ChatCompletionToolChoiceOption =
| 'none'
| 'auto'
| 'required'
| { type : 'function' ; function : { name : string } }
interface ChatCompletionMessageToolCall {
id : string ;
type : 'function' ;
function : {
name : string ;
arguments : string ; // JSON-encoded
};
}
Field Type Description idstringTool call ID. type'function'Always 'function'. function.namestringFunction name. function.argumentsstringJSON-encoded arguments.
type ChatCompletionCreateParams =
| ChatCompletionCreateParamsNonStreaming // stream?: false
| ChatCompletionCreateParamsStreaming // stream: true
interface ChatCompletionCreateParamsBase {
model : string ;
messages : ChatCompletionMessageParam [];
max_tokens ?: number ;
temperature ?: number ;
top_p ?: number ;
n ?: number ;
stop ?: string | string [] | null ;
presence_penalty ?: number ;
frequency_penalty ?: number ;
logprobs ?: boolean | null ;
top_logprobs ?: number | null ;
user ?: string ;
tools ?: ChatCompletionTool [];
tool_choice ?: ChatCompletionToolChoiceOption ;
parallel_tool_calls ?: boolean ;
}
Parameter Type Description modelstringModel slug. Browse models in the catalog . messagesChatCompletionMessageParam[]Conversation history. max_tokensnumberMax completion tokens. temperaturenumberSampling temperature (0–2). top_pnumberNucleus sampling. nnumberNumber of choices. stopstring | string[]Stop sequences. presence_penaltynumberPresence penalty (−2 to 2). frequency_penaltynumberFrequency penalty (−2 to 2). logprobsbooleanInclude log probabilities. top_logprobsnumberTop N logprobs per token. userstringEnd-user identifier. toolsChatCompletionTool[]Tool definitions. tool_choiceChatCompletionToolChoiceOptionTool invocation mode. parallel_tool_callsbooleanAllow parallel tool calls.
Returned by client.chat.completions.create() from POST /v1/chat/completions . This TypeScript interface matches the OpenAI Chat Completions API response exactly — the SDK performs no transformations.
interface ChatCompletion {
id : string ;
object : 'chat.completion' ;
created : number ;
model : string ;
choices : ChatCompletionChoice [];
usage : CompletionUsage ;
system_fingerprint : string ;
prompt_filter_results : PromptFilterResult [];
}
Field Type Description idstringCompletion ID. object'chat.completion'Object type. creatednumberUnix timestamp. modelstringModel used. choicesChatCompletionChoice[]Completion choices. usageCompletionUsageToken usage. system_fingerprintstringSystem fingerprint. prompt_filter_resultsPromptFilterResult[]Safety filter results for prompts. See Safety .
interface ChatCompletionChoice {
index : number ;
message : ChatCompletionMessage ;
finish_reason : string ;
logprobs : unknown ;
content_filter_results : ChoiceContentFilterResults ;
}
Field Type Description indexnumberChoice index. messageChatCompletionMessagerole, content, tool_calls, refusal.finish_reasonstring'stop' · 'length' · 'content_filter' · 'tool_calls' · null.logprobsunknownLog probability data. content_filter_resultsChoiceContentFilterResultsPer-category filter results.
interface ChatCompletionChunk {
id : string ;
object : 'chat.completion.chunk' ;
created : number ;
model : string ;
choices : ChatCompletionChunkChoice [];
usage : CompletionUsage | null ;
prompt_filter_results : PromptFilterResult [];
}
Streamed via AsyncIterable<ChatCompletionChunk>. See Streaming .
Field Type Description idstringChunk ID (same for all chunks in one completion). object'chat.completion.chunk'Object type. creatednumberUnix timestamp. modelstringModel used. choicesChatCompletionChunkChoice[]Chunk choices with delta. usageCompletionUsage | nullToken usage (only on final chunk). prompt_filter_resultsPromptFilterResult[]Safety filter results.
interface CompletionUsage {
prompt_tokens : number ;
completion_tokens : number ;
total_tokens : number ;
completion_tokens_details : CompletionTokensDetails ;
prompt_tokens_details : PromptTokensDetails ;
}
Field Type Description prompt_tokensnumberInput tokens. completion_tokensnumberOutput tokens. total_tokensnumberTotal tokens. completion_tokens_detailsCompletionTokensDetailsaccepted_prediction_tokens, audio_tokens, reasoning_tokens, rejected_prediction_tokens.prompt_tokens_detailsPromptTokensDetailsaudio_tokens, cached_tokens.
How is this guide?
Good Bad