Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
// SDK type re-exports — every SDK type used in this package's public API
// so consumers don't need to depend on @openrouter/sdk directly.

export type { RequestOptions } from '@openrouter/sdk/lib/sdks';

export type {
// Core request/response
BaseInputsUnion,
// Message & item types
ChatAssistantMessage,
ChatMessages,
EasyInputMessage,
EasyInputMessageContentUnion1,
EasyInputMessageRoleUnion,
// Error event
ErrorEvent,
FunctionCallItem,
FunctionCallOutputItem,
// Content input types (multimodal)
InputAudio,
InputFile,
InputImage,
InputMessageItem,
InputsUnion,
InputText,
InputVideo,
OpenResponsesResult,
// Output item types (StreamableOutputItem members)
OutputFileSearchCallItem,
OutputFunctionCallItem,
OutputImageGenerationCallItem,
OutputMessage,
OutputReasoningItem,
OutputWebSearchCallItem,
// Response output content
ResponseOutputText,
ResponsesRequest,
StreamEvents,
Usage,
} from '@openrouter/sdk/models';

// Clean item type aliases
export type {
AssistantMessageItem,
CallFileSearchItem,
CallFunctionToolItem,
CallImageGenerationItem,
CallWebSearchItem,
DeveloperMessageItem,
ErrorItem,
FunctionProgressItem,
FunctionResultItem,
Item,
NewUserMessageItem,
ReasoningItem,
SystemMessageItem,
UserMessageItem,
} from './lib/item-types.js';

// Message format compatibility helpers

// High-level model calling
Expand Down
100 changes: 100 additions & 0 deletions src/lib/item-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import type {
EasyInputMessage,
ErrorEvent,
FunctionCallOutputItem,
OutputFileSearchCallItem,
OutputFunctionCallItem,
OutputImageGenerationCallItem,
OutputMessage,
OutputReasoningItem,
OutputWebSearchCallItem,
} from '@openrouter/sdk/models';
import type { ToolPreliminaryResultEvent } from './tool-types.js';

/**
* Adds a required `id` field to a type, representing an item that has been
* persisted in conversation history (as opposed to newly created input).
* This is a local convention — the SDK's `EasyInputMessage` has no `id` field.
*/
type WithID<T> = T & {
id: string;
};

/** A function call initiated by the model */
export type CallFunctionToolItem = OutputFunctionCallItem;

/** An assistant message in the response output */
export type AssistantMessageItem = OutputMessage;

/** A new user message for input (not yet persisted, no id) */
export type NewUserMessageItem = EasyInputMessage & {
role: 'user';
};

/** A user message from conversation history (has an assigned id) */
export type UserMessageItem = WithID<EasyInputMessage> & {
role: 'user';
};

/** A system message from conversation history (has an assigned id) */
export type SystemMessageItem = WithID<EasyInputMessage> & {
role: 'system';
};

/** A developer message from conversation history (has an assigned id) */
export type DeveloperMessageItem = WithID<EasyInputMessage> & {
role: 'developer';
};

/** Reasoning output from the model */
export type ReasoningItem = OutputReasoningItem;

/** A file search call in the response output */
export type CallFileSearchItem = OutputFileSearchCallItem;

/**
* The output from a function call execution.
* `FunctionCallOutputItem` already declares `id?: string | null | undefined`,
* so no `WithID` wrapper is needed.
*/
export type FunctionResultItem = FunctionCallOutputItem;

/**
* A preliminary result event emitted during tool execution.
* `ToolPreliminaryResultEvent` uses `toolCallId` (not `id`) for identification.
*/
export type FunctionProgressItem = ToolPreliminaryResultEvent;

/** A web search call in the response output */
export type CallWebSearchItem = OutputWebSearchCallItem;

/** An image generation call in the response output */
export type CallImageGenerationItem = OutputImageGenerationCallItem;

/**
* A streaming error event.
* `ErrorEvent` has no `id` field; it uses `code`, `message`, `param`, and `sequenceNumber`.
*/
export type ErrorItem = ErrorEvent;

/**
* Union of all item types used by this package.
*
* This is not exhaustive over every possible SDK output item type —
* server tool items (e.g. `OutputDatetimeItem`, `OutputServerToolItem`)
* are not included. Extend this union if you need to handle those.
*/
export type Item =
| AssistantMessageItem
| UserMessageItem
| SystemMessageItem
| DeveloperMessageItem
| NewUserMessageItem
| CallFunctionToolItem
| ReasoningItem
| CallFileSearchItem
| FunctionResultItem
| FunctionProgressItem
| CallWebSearchItem
| CallImageGenerationItem
| ErrorItem;
Loading