TypeScript SDKReference

Responses Types

TypeScript types for the Responses API, including reasoning control and multi-turn conversations.

See Responses for usage.

ResponsesCreateParams

interface ResponsesCreateParams {
  model: string;
  input: string | ResponsesInputMessage[];
  instructions?: string | null;
  stream?: boolean | null;
  temperature?: number;
  top_p?: number;
  max_output_tokens?: number | null;
  tools?: ChatCompletionTool[];
  tool_choice?: ChatCompletionToolChoiceOption;
  parallel_tool_calls?: boolean;
  reasoning?: {
    effort?: 'none' | 'low' | 'medium' | 'high';
    summary?: 'auto' | 'concise' | 'detailed';
  };
  text?: {
    format?: unknown;
    verbosity?: unknown;
  };
  store?: boolean;
  previous_response_id?: string | null;
  metadata?: Record<string, unknown>;
  user?: string | null;
  truncation?: string;
  frequency_penalty?: number;
  presence_penalty?: number;
}
ParameterTypeDescription
modelstringModel slug.
inputstring | ResponsesInputMessage[]Prompt or messages.
instructionsstringSystem-level instructions.
streambooleantrue for SSE streaming.
temperaturenumberSampling temperature.
top_pnumberNucleus sampling.
max_output_tokensnumberMaximum output tokens.
toolsChatCompletionTool[]Tool definitions.
tool_choiceChatCompletionToolChoiceOptionTool invocation mode.
parallel_tool_callsbooleanAllow parallel calls.
reasoning{ effort?, summary? }Reasoning control. effort: 'none' · 'low' · 'medium' · 'high'. summary: 'auto' · 'concise' · 'detailed'.
text{ format?, verbosity? }Output formatting options.
storebooleanPersist server-side for multi-turn.
previous_response_idstringChain to a prior response.
metadataRecord<string, unknown>Arbitrary labels.
userstringEnd-user identifier.
truncationstring'auto' or 'disabled'.
frequency_penaltynumberFrequency penalty.
presence_penaltynumberPresence penalty.

ResponsesResponse

Returned by client.responses.create() from POST /v1/responses. This TypeScript interface matches the API JSON response exactly — the SDK performs no transformations.

interface ResponsesResponse {
  id: string;
  object: 'response';
  created_at: number;
  status: string;
  model: string;
  output: ResponsesOutputMessage[];
  usage: ResponsesUsage;
  content_filters: ResponsesContentFilter[];
  instructions: string | null;
  previous_response_id: string | null;
  reasoning: object;
  store: boolean;
  metadata: Record<string, unknown>;
}
FieldTypeDescription
idstringResponse ID (chainable via previous_response_id).
object'response'Object type.
created_atnumberUnix timestamp.
statusstring'completed' · 'in_progress' · 'failed'.
modelstringModel used.
outputResponsesOutputMessage[]Output messages.
usageResponsesUsageToken counts with details.
content_filtersResponsesContentFilter[]Safety filter results. See Safety.
instructionsstringSystem instructions used.
previous_response_idstringParent response.
reasoningobjectApplied reasoning settings.
storebooleanWhether persisted.
metadataRecord<string, unknown>User metadata.

ResponsesInputMessage

interface ResponsesInputMessage {
  role: 'system' | 'user' | 'assistant' | 'tool';
  content: string | ContentPart[];
  name?: string;
  tool_call_id?: string;
}
FieldTypeDescription
role'system' | 'user' | 'assistant' | 'tool'Message role.
contentstring | ContentPart[]Text or multi-part.
namestringOptional name.
tool_call_idstringTool call ID (for role: 'tool').

ResponsesOutputMessage

interface ResponsesOutputMessage {
  id: string;
  type: string;
  status: string;
  role: string;
  content: ResponsesOutputContent[];
}
FieldTypeDescription
idstringMessage ID.
typestringMessage type.
statusstringMessage status.
rolestringRole.
contentResponsesOutputContent[]Content parts.

ResponsesUsage

interface ResponsesUsage {
  input_tokens: number;
  output_tokens: number;
  total_tokens: number;
  input_tokens_details: { cached_tokens?: number };
  output_tokens_details: { reasoning_tokens?: number };
}
FieldTypeDescription
input_tokensnumberInput tokens.
output_tokensnumberOutput tokens.
total_tokensnumberTotal tokens.
input_tokens_details{ cached_tokens? }Cached token details.
output_tokens_details{ reasoning_tokens? }Reasoning token details.

ResponsesContentFilter

interface ResponsesContentFilter {
  blocked: boolean;
  source_type: 'prompt' | 'completion';
  content_filter_results: object;
}
FieldTypeDescription
blockedbooleanWhether content was blocked.
source_type'prompt' | 'completion'Filter source.
content_filter_resultsobjectPer-category results (hate, sexual, violence, self_harm, jailbreak, etc.).

Streaming Events

type ResponsesStreamEvent =
  | ResponsesCreatedEvent         // type: 'response.created'
  | ResponsesInProgressEvent      // type: 'response.in_progress'
  | ResponsesCompletedEvent       // type: 'response.completed'
  | ResponsesOutputItemAddedEvent // type: 'response.output_item.added'
  | ResponsesOutputItemDoneEvent  // type: 'response.output_item.done'
  | ResponsesContentPartAddedEvent// type: 'response.content_part.added'
  | ResponsesContentPartDoneEvent // type: 'response.content_part.done'
  | ResponsesOutputTextDeltaEvent // type: 'response.output_text.delta'
  | ResponsesOutputTextDoneEvent  // type: 'response.output_text.done'

ResponsesStreamEvent is a discriminated union on type. See Streaming Events. Each event extends ResponsesEventBase with sequence_number: number.

Key Events

EventFieldsDescription
ResponsesOutputTextDeltaEventoutput_index, content_index, item_id, deltaIncremental text.
ResponsesOutputTextDoneEventoutput_index, content_index, item_id, textFull accumulated text.
ResponsesCompletedEventresponseFull ResponsesResponse with usage.

How is this guide?

On this page