GlexirDocs
Dashboard

SDK

Type reference

@glexir/sdk exports a TypeScript type for every request, response and stream event it handles. This page lists every export, grouped by area, with a one-line description and a link to the page that covers it in depth.

Import types with import type. The Responses API object is named Response, like the global Response, so alias it:

TypeScript
import Glexir from "@glexir/sdk";
import type { ResponseCreateParamsNonStreaming, ResponseInputItem, Response as GlexirResponse } from "@glexir/sdk";

const glexir = new Glexir();

const input: ResponseInputItem[] = [{ role: "user", content: "Name three planets." }];
const params: ResponseCreateParamsNonStreaming = { model: "gpt-5.4-mini", input, store: false };

const response: GlexirResponse = await glexir.responses.create(params);
console.log(response.output_text);

Request parameter types accept unknown keys where OpenAI adds parameters often (ResponseCreateParamsBase, ChatCompletionCreateParamsBase, EmbeddingCreateParams, TranscriptionCreateParamsBase). Unknown keys are sent unchanged. Model and enum types such as ChatModel and ServiceTier list known values and also accept any string.

Client and runtime

ExportKindWhat it isPage
GlexirclassThe client. Also the default export.Client configuration
ClientOptionstypeOptions for new Glexir(): apiKey, baseURL, timeout, maxRetries, fetch, defaultHeaders.Client configuration
RequestOptionstypeThe last argument of every method: signal, timeout, maxRetries, headers, idempotencyKey.Client configuration
DEFAULT_BASE_URLconst"https://api.glexir.com/v1", used when no baseURL or GLEXIR_BASE_URL is set.Client configuration
VERSIONconstThe SDK version, "0.2.0". Sent as x-glexir-sdk: js/<VERSION>.Client configuration
APIPromise<T>classWhat every method returns. Await it, or call withRawResponse() or asResponse().Client configuration
WithRawResponse<T>type{ data, response, requestId }, from withRawResponse().Client configuration
CursorPage<Item>classOne page of a list, with hasNextPage(), getNextPage() and iterPages().Pagination
PagePromise<Item>classWhat list methods return: a promise for the first page that you can also iterate with for await.Pagination
CursorPageParamstype{ after?, limit? }, the base of every list params type.Pagination
Stream<Item>classA raw server-sent event stream, from create({ stream: true }).Streaming
ServerSentEventtype{ event, data, raw }, one parsed SSE message.Streaming
ResponseStreamclassThe helper returned by responses.stream().Streaming
ChatCompletionStreamclassThe helper returned by chat.completions.stream().Streaming
toFile()functionWraps bytes, a Blob, a stream or a Response in a named File.Audio
UploadabletypeFile | Blob | Uint8Array | ArrayBuffer | ReadableStream<Uint8Array> | Response.Audio
toBatchJSONL()functionBuilds a batch.jsonl File from request lines.Batches
toStrictJsonSchema()functionRewrites a JSON Schema for strict structured output.Responses

Errors

ExportWhat it isPage
GlexirErrorBase class of every SDK error.Errors & retries
APIErrorAny non-2xx response, or an error event inside a stream.Errors & retries
APIErrorBodyThe error object of an error body: message, type, code, param and extra fields.Errors & retries
BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerErrorAPIError subclasses for 400, 401, 403, 404, 409, 422, 429 and 500+.Errors & retries
APIConnectionError, APIConnectionTimeoutError, APIUserAbortErrorNo HTTP response: network failure, timeout, or your signal. status is undefined.Errors & retries
LengthFinishReasonError, ContentFilterFinishReasonErrorThrown by parse() when output was truncated or filtered.Errors & retries
StrictSchemaErrorThrown by toStrictJsonSchema().Errors & retries

Shared

ExportWhat it is
MetadataRecord<string, string>. Up to 16 pairs; keys up to 64 characters, values up to 512.
ChatModelText model IDs, for example gpt-5.4-mini. Accepts any string.
ResponsesModelChatModel plus the Responses-only -pro models.
ReasoningEffortnone, minimal, low, medium, high, xhigh, max, or any string.
ServiceTierauto, default, flex, scale, priority, fast, ultrafast, or any string. See Pricing.
Verbositylow, medium or high.
ErrorObject{ code, message, param, type }, the error object in error bodies and stream error fields.
PromptCacheBreakpoint{ mode: "explicit" }, set on a content part to mark an explicit cache breakpoint.
PromptCacheOptions{ mode?, ttl? } for Chat Completions.
ModerationConfigInline moderation settings: { model, policy? }.
ModerationResult, ModerationResults, ModerationErrorModeration output returned when you set moderation.
FunctionDefinition, FunctionParametersA function's name, description?, parameters? (JSON Schema) and strict?. Used by Chat Completions tools.
CustomToolInputFormat, CustomToolInputFormatText, CustomToolInputFormatGrammarA custom tool's input format on the Responses API: { type: "text" } or { type: "grammar", syntax, definition }.
ResponseFormatText, ResponseFormatJSONObject, ResponseFormatJSONSchema, JSONSchemaFormatChat Completions response_format values. JSONSchemaFormat is the json_schema object: name, schema?, description?, strict?.
ListResponse<Item>A cursor list body: { object: "list", data, has_more, first_id?, last_id? }.
DeletedObject<TObject>{ id, deleted, object }.

Responses

Covered on Responses and Streaming.

ExportWhat it is
ResponseCreateParams, ResponseCreateParamsBase, ResponseCreateParamsNonStreaming, ResponseCreateParamsStreamingParameters for responses.create(). See Create parameters.
ResponseStreamParams, ResponseStreamResumeParamsParameters for responses.stream(): create parameters, or { response_id, starting_after? } to resume a background stream.
ParseOptions<T>, ParsedResponse<T>RequestOptions plus validate?, and the Response plus output_parsed, for responses.parse().
ResponseRetrieveParams{ include?, include_obfuscation?, starting_after? } for responses.retrieve(). The method also takes stream in the same object.
InputItemListParams{ after?, limit?, order?, include? } for responses.inputItems.list().
InputTokenCountParams, InputTokenCountResponseBody and result of responses.inputTokens.count().
ResponseCompactParams, CompactedResponseBody and result of responses.compact().
ResponseThe response object. output_text is added by the SDK.
ResponseStatusqueued, in_progress, completed, incomplete, failed or cancelled.
ResponseUsageToken usage: input_tokens, input_tokens_details, output_tokens, output_tokens_details, total_tokens.
ResponseError{ code, message } on a failed response.
ResponseInputstring | ResponseInputItem[].
ResponseInputItemAny item you can send as input.
ResponseOutputItemAny item in response.output.
ResponseItemA stored item, from inputItems.list() and conversation item endpoints.
EasyInputMessage{ role, content, phase? }, the simplest message form.
ResponseInputMessageA typed input message with user, system or developer role and content parts.
ResponseOutputMessageAn assistant message: id, status, content, phase?.
MessagePhasecommentary or final_answer. Keep it on assistant messages you replay.
ResponseInputContentResponseInputText | ResponseInputImage | ResponseInputFile.
ResponseInputText{ type: "input_text", text }.
ResponseInputImage{ type: "input_image", detail, image_url?, file_id? }.
ResponseInputFile{ type: "input_file", file_url?, file_data?, file_id?, filename?, detail? }.
ResponseOutputText{ type: "output_text", text, annotations, logprobs? }.
ResponseOutputRefusal{ type: "refusal", refusal }.
AnnotationFileCitation | URLCitation | ContainerFileCitation | FilePath, attached to output text.
FileCitation, URLCitation, ContainerFileCitation, FilePathThe annotation shapes. Citations from hosted tools do not occur on Glexir, because hosted tools are not available.
Logprob{ token, bytes, logprob, top_logprobs } for output text.
ResponseReasoningItemA reasoning item, with encrypted_content when requested. Replay it unchanged.
ResponseFunctionToolCall, ResponseFunctionCallOutputA function call from the model and the output you send back.
ResponseCustomToolCall, ResponseCustomToolCallOutputA custom tool call and its output.
ToolCallerWho made a tool call: { type: "direct" } or { type: "program", caller_id }.
ResponseCompactionItemAn opaque compaction item from compact() or automatic compaction.
ResponseCompactionTrigger{ type: "compaction_trigger" }. Asks the model to compact now; must be the last input item.
ResponseItemReference{ type?: "item_reference", id }, a reference to a stored item.
ResponseConfigurationUpdateChanges reasoning effort for later turns.
Tool, FunctionTool, CustomTool, NamespaceToolThe tool types Glexir accepts. See Tools.
ToolChoicenone, auto, required, a named function or custom tool, or allowed_tools.
ResponseTextConfig{ format?, verbosity? }.
ResponseFormatTextConfig, ResponseFormatTextJSONSchemaConfigtext.format values: text, json_object, or { type: "json_schema", name, schema, description?, strict? }.
Reasoning{ effort?, summary?, context?, mode? }.
ResponseIncludableValues for include, such as reasoning.encrypted_content.
ResponsePromptCacheOptions{ mode?, ttl?, prewarm?, comparison_response_id? }.
ContextManagement{ type: "compaction", compact_threshold? }.
ResponseStreamEvent and the 28 event typesEvery Responses stream event, from ResponseQueuedEvent to ResponseKeepaliveEvent. Listed in Event types.

Conversations

Covered on Conversations.

ExportWhat it is
Conversation{ id, object: "conversation", created_at, metadata }.
ConversationCreateParams{ items?, metadata? }.
ConversationUpdateParams{ metadata }.
ConversationDeleted{ id, deleted, object: "conversation.deleted" }.
ConversationItemSame as ResponseItem.
ConversationItemList{ object: "list", data, first_id, last_id, has_more }, from items.create().
ItemCreateParams{ items, include? }.
ItemListParams{ after?, limit?, order?, include? }.
ItemRetrieveParams{ include? }.

Chat Completions

Covered on Chat Completions.

ExportWhat it is
ChatCompletionCreateParams, ChatCompletionCreateParamsBase, ChatCompletionCreateParamsNonStreaming, ChatCompletionCreateParamsStreamingParameters for chat.completions.create().
ParsedChatCompletion<T>, ParsedChatCompletionMessage<T>, ParsedFunctionToolCallResults of chat.completions.parse().
ChatCompletionThe completion object.
ChatCompletionChoice{ index, finish_reason, logprobs, message }.
ChatCompletionMessageThe assistant reply: role, content, refusal, tool_calls?, annotations?.
ChatCompletionFinishReasonstop, length, tool_calls, content_filter or function_call.
ChatCompletionTokenLogprob{ token, bytes, logprob, top_logprobs }.
CompletionUsageprompt_tokens, completion_tokens, total_tokens and their details.
ChatCompletionChunkOne streamed chunk.
ChatCompletionChunkToolCallDeltaA tool-call fragment in a chunk, merged by index.
ChatCompletionMessageParamAny input message.
ChatCompletionDeveloperMessageParam, ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam, ChatCompletionAssistantMessageParam, ChatCompletionToolMessageParamInput messages by role. See Messages.
ChatCompletionContentPartA user content part: text, image or file.
ChatCompletionContentPartText{ type: "text", text }.
ChatCompletionContentPartImage{ type: "image_url", image_url: { url, detail? } }.
ChatCompletionContentPartFile{ type: "file", file: { file_data?, file_id?, filename? } }.
ChatCompletionContentPartRefusal{ type: "refusal", refusal }, in assistant message content.
ChatCompletionMessageToolCallChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall.
ChatCompletionMessageFunctionToolCall{ id, type: "function", function: { name, arguments } }.
ChatCompletionMessageCustomToolCall{ id, type: "custom", custom: { name, input } }.
ChatCompletionTool, ChatCompletionFunctionTool, ChatCompletionCustomToolTools for Chat Completions. See Tools.
ChatCustomToolFormatA custom tool's format on Chat Completions: { type: "text" } or { type: "grammar", grammar: { definition, syntax } }.
ChatCompletionToolChoiceOptionnone, auto, required, a named function or custom tool, or allowed_tools.
ChatCompletionUpdateParams{ metadata }.
ChatCompletionListParams{ after?, limit?, metadata?, model?, order? }.
ChatCompletionDeleted{ id, deleted, object: "chat.completion.deleted" }.
ChatCompletionStoreMessageA stored message: a ChatCompletionMessage with id and content_parts?.
MessageListParams{ after?, limit?, order? }.

Audio

Covered on Audio.

ExportWhat it is
TranscriptionModelSpeech-to-text model IDs. Accepts any string.
AudioResponseFormatjson, text, srt, verbose_json, vtt or diarized_json.
TranscriptionCreateParamsBaseParameters for audio.transcriptions.create().
VadConfig{ type: "server_vad", prefix_padding_ms?, silence_duration_ms?, threshold? }.
Transcription, TranscriptionVerbose, TranscriptionDiarizedResults for json, verbose_json and diarized_json.
TranscriptionSegment, TranscriptionWord, TranscriptionDiarizedSegmentSegments and words inside those results.
TranscriptionLogprob{ token?, bytes?, logprob? }.
TranscriptionUsage, TranscriptionDurationUsage, TranscriptionTokenUsage{ type: "duration", seconds } or { type: "tokens", ... }.
TranscriptionStreamEvent, TranscriptionTextDeltaEvent, TranscriptionTextDoneEvent, TranscriptionTextSegmentEventEvents from create({ stream: true }).
TranslationCreateParams, Translation, TranslationVerboseParameters and results of the deprecated audio.translations.create().

Embeddings, files, batches and models

ExportWhat it isPage
EmbeddingModelEmbedding model IDs. Accepts any string.Embeddings
EmbeddingCreateParams{ model, input, dimensions?, encoding_format?, user? }.Embeddings
Embedding<TVector>{ object: "embedding", index, embedding }.Embeddings
CreateEmbeddingResponse<TVector>{ object: "list", data, model, usage }.Embeddings
FilePurposeuser_data or batch on Glexir. The type also lists OpenAI purposes the gateway rejects.Files
FileObjectA file: id, bytes, created_at, filename, purpose, expires_at?.Files
FileCreateParams{ file, purpose, expires_after? }.Files
FileListParams{ after?, limit?, order?, purpose? }.Files
FileDeleted{ id, deleted, object: "file" }.Files
BatchEndpoint/v1/responses, /v1/chat/completions or /v1/embeddings.Batches
BatchCreateParams{ input_file_id, endpoint, completion_window, metadata?, output_expires_after? }.Batches
BatchStatusvalidating, failed, in_progress, finalizing, completed, expired, cancelling or cancelled.Batches
BatchA batch job.Batches
BatchListParams{ after?, limit? }.Batches
BatchRequestLine<TBody>One line of a batch input file: { custom_id, method, url, body }.Batches
Model{ id, object: "model", created, owned_by, shutdown_date? }.Models