@openrouter/sdk 1.2.136 → 1.2.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/funcs/internsChat.d.ts +34 -0
- package/esm/funcs/internsChat.js +133 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/models/errors/index.d.ts +1 -0
- package/esm/models/errors/index.js +1 -0
- package/esm/models/errors/internchaterrorresponse.d.ts +31 -0
- package/esm/models/errors/internchaterrorresponse.js +35 -0
- package/esm/models/incompletedetails.d.ts +4 -4
- package/esm/models/incompletedetails.js +3 -4
- package/esm/models/index.d.ts +23 -0
- package/esm/models/index.js +23 -0
- package/esm/models/internapprovalmode.d.ts +16 -0
- package/esm/models/internapprovalmode.js +15 -0
- package/esm/models/internchatassistantmessage.d.ts +24 -0
- package/esm/models/internchatassistantmessage.js +22 -0
- package/esm/models/internchatchoice.d.ts +37 -0
- package/esm/models/internchatchoice.js +33 -0
- package/esm/models/internchatcompletionchunk.d.ts +48 -0
- package/esm/models/internchatcompletionchunk.js +34 -0
- package/esm/models/internchatcompletionrequest.d.ts +40 -0
- package/esm/models/internchatcompletionrequest.js +25 -0
- package/esm/models/internchatdelta.d.ts +24 -0
- package/esm/models/internchatdelta.js +28 -0
- package/esm/models/internchatdevelopermessage.d.ts +21 -0
- package/esm/models/internchatdevelopermessage.js +15 -0
- package/esm/models/internchatechoedtoolcall.d.ts +21 -0
- package/esm/models/internchatechoedtoolcall.js +15 -0
- package/esm/models/internchatechoedtoolcallfunction.d.ts +17 -0
- package/esm/models/internchatechoedtoolcallfunction.js +14 -0
- package/esm/models/internchaterror.d.ts +22 -0
- package/esm/models/internchaterror.js +17 -0
- package/esm/models/internchaterrormetadata.d.ts +44 -0
- package/esm/models/internchaterrormetadata.js +38 -0
- package/esm/models/internchatmessage.d.ts +16 -0
- package/esm/models/internchatmessage.js +22 -0
- package/esm/models/internchatmessagecontent.d.ts +12 -0
- package/esm/models/internchatmessagecontent.js +12 -0
- package/esm/models/internchatprompttokensdetails.d.ts +13 -0
- package/esm/models/internchatprompttokensdetails.js +19 -0
- package/esm/models/internchatstreamerror.d.ts +22 -0
- package/esm/models/internchatstreamerror.js +17 -0
- package/esm/models/internchatstreamingresponse.d.ts +17 -0
- package/esm/models/internchatstreamingresponse.js +29 -0
- package/esm/models/internchatsystemmessage.d.ts +21 -0
- package/esm/models/internchatsystemmessage.js +15 -0
- package/esm/models/internchattextpart.d.ts +24 -0
- package/esm/models/internchattextpart.js +19 -0
- package/esm/models/internchattoolcall.d.ts +30 -0
- package/esm/models/internchattoolcall.js +23 -0
- package/esm/models/internchattoolcallfunction.d.ts +24 -0
- package/esm/models/internchattoolcallfunction.js +20 -0
- package/esm/models/internchattoolmessage.d.ts +23 -0
- package/esm/models/internchattoolmessage.js +21 -0
- package/esm/models/internchatusage.d.ts +24 -0
- package/esm/models/internchatusage.js +27 -0
- package/esm/models/internchatusermessage.d.ts +21 -0
- package/esm/models/internchatusermessage.js +15 -0
- package/esm/models/operations/createinternchatcompletion.d.ts +61 -0
- package/esm/models/operations/createinternchatcompletion.js +24 -0
- package/esm/models/operations/index.d.ts +1 -0
- package/esm/models/operations/index.js +1 -0
- package/esm/sdk/interns.d.ts +20 -0
- package/esm/sdk/interns.js +22 -0
- package/jsr.json +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { ClosedEnum } from "../types/enums.js";
|
|
3
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
5
|
+
import { InternChatToolCallFunction } from "./internchattoolcallfunction.js";
|
|
6
|
+
export declare const InternChatToolCallType: {
|
|
7
|
+
readonly Function: "function";
|
|
8
|
+
};
|
|
9
|
+
export type InternChatToolCallType = ClosedEnum<typeof InternChatToolCallType>;
|
|
10
|
+
/**
|
|
11
|
+
* An `openrouter.provide_input` request. The run pauses on the daemon until a `tool` message answers it, the caller cancels it, or its interaction deadline passes.
|
|
12
|
+
*/
|
|
13
|
+
export type InternChatToolCall = {
|
|
14
|
+
/**
|
|
15
|
+
* The single tool this endpoint calls, asking the caller for input.
|
|
16
|
+
*/
|
|
17
|
+
function: InternChatToolCallFunction;
|
|
18
|
+
/**
|
|
19
|
+
* The interaction id. Send it back as `tool_call_id` on the `tool` message that answers it.
|
|
20
|
+
*/
|
|
21
|
+
id: string;
|
|
22
|
+
index: number;
|
|
23
|
+
type: InternChatToolCallType;
|
|
24
|
+
};
|
|
25
|
+
/** @internal */
|
|
26
|
+
export declare const InternChatToolCallType$inboundSchema: z.ZodEnum<typeof InternChatToolCallType>;
|
|
27
|
+
/** @internal */
|
|
28
|
+
export declare const InternChatToolCall$inboundSchema: z.ZodType<InternChatToolCall, unknown>;
|
|
29
|
+
export declare function internChatToolCallFromJSON(jsonString: string): SafeParseResult<InternChatToolCall, SDKValidationError>;
|
|
30
|
+
//# sourceMappingURL=internchattoolcall.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: ab9593cbcfd4
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { InternChatToolCallFunction$inboundSchema, } from "./internchattoolcallfunction.js";
|
|
8
|
+
export const InternChatToolCallType = {
|
|
9
|
+
Function: "function",
|
|
10
|
+
};
|
|
11
|
+
/** @internal */
|
|
12
|
+
export const InternChatToolCallType$inboundSchema = z.enum(InternChatToolCallType);
|
|
13
|
+
/** @internal */
|
|
14
|
+
export const InternChatToolCall$inboundSchema = z.object({
|
|
15
|
+
function: InternChatToolCallFunction$inboundSchema,
|
|
16
|
+
id: z.string(),
|
|
17
|
+
index: z.int(),
|
|
18
|
+
type: InternChatToolCallType$inboundSchema,
|
|
19
|
+
});
|
|
20
|
+
export function internChatToolCallFromJSON(jsonString) {
|
|
21
|
+
return safeParse(jsonString, (x) => InternChatToolCall$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InternChatToolCall' from JSON`);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=internchattoolcall.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { ClosedEnum } from "../types/enums.js";
|
|
3
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
5
|
+
export declare const InternChatToolCallFunctionName: {
|
|
6
|
+
readonly OpenrouterProvideInput: "openrouter.provide_input";
|
|
7
|
+
};
|
|
8
|
+
export type InternChatToolCallFunctionName = ClosedEnum<typeof InternChatToolCallFunctionName>;
|
|
9
|
+
/**
|
|
10
|
+
* The single tool this endpoint calls, asking the caller for input.
|
|
11
|
+
*/
|
|
12
|
+
export type InternChatToolCallFunction = {
|
|
13
|
+
/**
|
|
14
|
+
* A JSON object string describing the interaction. A permission request is `{"kind":"permission","operation":<tool name or null>,"options":[<permission option kinds>]}`. A question is `{"kind":"elicitation","message":<question>,"fields":[<field descriptors>]}`.
|
|
15
|
+
*/
|
|
16
|
+
arguments: string;
|
|
17
|
+
name: InternChatToolCallFunctionName;
|
|
18
|
+
};
|
|
19
|
+
/** @internal */
|
|
20
|
+
export declare const InternChatToolCallFunctionName$inboundSchema: z.ZodEnum<typeof InternChatToolCallFunctionName>;
|
|
21
|
+
/** @internal */
|
|
22
|
+
export declare const InternChatToolCallFunction$inboundSchema: z.ZodType<InternChatToolCallFunction, unknown>;
|
|
23
|
+
export declare function internChatToolCallFunctionFromJSON(jsonString: string): SafeParseResult<InternChatToolCallFunction, SDKValidationError>;
|
|
24
|
+
//# sourceMappingURL=internchattoolcallfunction.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 5a9b88a1d80e
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
export const InternChatToolCallFunctionName = {
|
|
8
|
+
OpenrouterProvideInput: "openrouter.provide_input",
|
|
9
|
+
};
|
|
10
|
+
/** @internal */
|
|
11
|
+
export const InternChatToolCallFunctionName$inboundSchema = z.enum(InternChatToolCallFunctionName);
|
|
12
|
+
/** @internal */
|
|
13
|
+
export const InternChatToolCallFunction$inboundSchema = z.object({
|
|
14
|
+
arguments: z.string(),
|
|
15
|
+
name: InternChatToolCallFunctionName$inboundSchema,
|
|
16
|
+
});
|
|
17
|
+
export function internChatToolCallFunctionFromJSON(jsonString) {
|
|
18
|
+
return safeParse(jsonString, (x) => InternChatToolCallFunction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InternChatToolCallFunction' from JSON`);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=internchattoolcallfunction.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { InternChatMessageContent, InternChatMessageContent$Outbound } from "./internchatmessagecontent.js";
|
|
3
|
+
/**
|
|
4
|
+
* The answer to an `openrouter.provide_input` tool call. `tool_call_id` is the streamed tool call id and `session_id` must name the same session. For a permission, `content` is one of the offered option kinds (`allow_once`, `allow_always`, `reject_once`, `reject_always`) or `cancel`. For a question (elicitation), `content` is a JSON object string with `action` (`accept`, `decline` or `cancel`) and, for `accept`, `content` holding the field values. The answer is delivered to the run that asked. It never starts a new run.
|
|
5
|
+
*/
|
|
6
|
+
export type InternChatToolMessage = {
|
|
7
|
+
/**
|
|
8
|
+
* Message text as a string or a list of text parts. Assistant history may carry null. Only the last message is read; earlier messages are accepted so ordinary clients can resend history.
|
|
9
|
+
*/
|
|
10
|
+
content: InternChatMessageContent | null;
|
|
11
|
+
role: "tool";
|
|
12
|
+
toolCallId: string;
|
|
13
|
+
};
|
|
14
|
+
/** @internal */
|
|
15
|
+
export type InternChatToolMessage$Outbound = {
|
|
16
|
+
content: InternChatMessageContent$Outbound | null;
|
|
17
|
+
role: "tool";
|
|
18
|
+
tool_call_id: string;
|
|
19
|
+
};
|
|
20
|
+
/** @internal */
|
|
21
|
+
export declare const InternChatToolMessage$outboundSchema: z.ZodType<InternChatToolMessage$Outbound, InternChatToolMessage>;
|
|
22
|
+
export declare function internChatToolMessageToJSON(internChatToolMessage: InternChatToolMessage): string;
|
|
23
|
+
//# sourceMappingURL=internchattoolmessage.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 8ef92162c037
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
import { remap as remap$ } from "../lib/primitives.js";
|
|
7
|
+
import { InternChatMessageContent$outboundSchema, } from "./internchatmessagecontent.js";
|
|
8
|
+
/** @internal */
|
|
9
|
+
export const InternChatToolMessage$outboundSchema = z.object({
|
|
10
|
+
content: z.nullable(InternChatMessageContent$outboundSchema),
|
|
11
|
+
role: z.literal("tool"),
|
|
12
|
+
toolCallId: z.string(),
|
|
13
|
+
}).transform((v) => {
|
|
14
|
+
return remap$(v, {
|
|
15
|
+
toolCallId: "tool_call_id",
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
export function internChatToolMessageToJSON(internChatToolMessage) {
|
|
19
|
+
return JSON.stringify(InternChatToolMessage$outboundSchema.parse(internChatToolMessage));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=internchattoolmessage.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
3
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
4
|
+
import { InternChatPromptTokensDetails } from "./internchatprompttokensdetails.js";
|
|
5
|
+
/**
|
|
6
|
+
* Token usage for the run as the daemon reported it, on the final chunk before `[DONE]`. `null` when the daemon reported none, and always `null` after `tool_calls` because the turn is not over.
|
|
7
|
+
*/
|
|
8
|
+
export type InternChatUsage = {
|
|
9
|
+
completionTokens: number;
|
|
10
|
+
/**
|
|
11
|
+
* The cost of the run in USD, when the daemon reported one.
|
|
12
|
+
*/
|
|
13
|
+
cost?: number | undefined;
|
|
14
|
+
promptTokens: number;
|
|
15
|
+
/**
|
|
16
|
+
* Prompt tokens served from cache, when the daemon reported them.
|
|
17
|
+
*/
|
|
18
|
+
promptTokensDetails?: InternChatPromptTokensDetails | undefined;
|
|
19
|
+
totalTokens: number;
|
|
20
|
+
};
|
|
21
|
+
/** @internal */
|
|
22
|
+
export declare const InternChatUsage$inboundSchema: z.ZodType<InternChatUsage, unknown>;
|
|
23
|
+
export declare function internChatUsageFromJSON(jsonString: string): SafeParseResult<InternChatUsage, SDKValidationError>;
|
|
24
|
+
//# sourceMappingURL=internchatusage.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 49d346597315
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
import { remap as remap$ } from "../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../lib/schemas.js";
|
|
8
|
+
import { InternChatPromptTokensDetails$inboundSchema, } from "./internchatprompttokensdetails.js";
|
|
9
|
+
/** @internal */
|
|
10
|
+
export const InternChatUsage$inboundSchema = z.object({
|
|
11
|
+
completion_tokens: z.int(),
|
|
12
|
+
cost: z.number().optional(),
|
|
13
|
+
prompt_tokens: z.int(),
|
|
14
|
+
prompt_tokens_details: InternChatPromptTokensDetails$inboundSchema.optional(),
|
|
15
|
+
total_tokens: z.int(),
|
|
16
|
+
}).transform((v) => {
|
|
17
|
+
return remap$(v, {
|
|
18
|
+
"completion_tokens": "completionTokens",
|
|
19
|
+
"prompt_tokens": "promptTokens",
|
|
20
|
+
"prompt_tokens_details": "promptTokensDetails",
|
|
21
|
+
"total_tokens": "totalTokens",
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
export function internChatUsageFromJSON(jsonString) {
|
|
25
|
+
return safeParse(jsonString, (x) => InternChatUsage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InternChatUsage' from JSON`);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=internchatusage.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { InternChatMessageContent, InternChatMessageContent$Outbound } from "./internchatmessagecontent.js";
|
|
3
|
+
/**
|
|
4
|
+
* A user message. When it is the last message its text is the prompt for a new run, at most 32000 characters.
|
|
5
|
+
*/
|
|
6
|
+
export type InternChatUserMessage = {
|
|
7
|
+
/**
|
|
8
|
+
* Message text as a string or a list of text parts. Assistant history may carry null. Only the last message is read; earlier messages are accepted so ordinary clients can resend history.
|
|
9
|
+
*/
|
|
10
|
+
content: InternChatMessageContent | null;
|
|
11
|
+
role: "user";
|
|
12
|
+
};
|
|
13
|
+
/** @internal */
|
|
14
|
+
export type InternChatUserMessage$Outbound = {
|
|
15
|
+
content: InternChatMessageContent$Outbound | null;
|
|
16
|
+
role: "user";
|
|
17
|
+
};
|
|
18
|
+
/** @internal */
|
|
19
|
+
export declare const InternChatUserMessage$outboundSchema: z.ZodType<InternChatUserMessage$Outbound, InternChatUserMessage>;
|
|
20
|
+
export declare function internChatUserMessageToJSON(internChatUserMessage: InternChatUserMessage): string;
|
|
21
|
+
//# sourceMappingURL=internchatusermessage.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 6d3909ea9433
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
import { InternChatMessageContent$outboundSchema, } from "./internchatmessagecontent.js";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export const InternChatUserMessage$outboundSchema = z.object({
|
|
9
|
+
content: z.nullable(InternChatMessageContent$outboundSchema),
|
|
10
|
+
role: z.literal("user"),
|
|
11
|
+
});
|
|
12
|
+
export function internChatUserMessageToJSON(internChatUserMessage) {
|
|
13
|
+
return JSON.stringify(InternChatUserMessage$outboundSchema.parse(internChatUserMessage));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=internchatusermessage.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import * as models from "../index.js";
|
|
3
|
+
export type CreateInternChatCompletionGlobals = {
|
|
4
|
+
/**
|
|
5
|
+
* The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This is used to track API usage per application.
|
|
9
|
+
*/
|
|
10
|
+
httpReferer?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
*/
|
|
16
|
+
appTitle?: string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
*/
|
|
22
|
+
appCategories?: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
export type CreateInternChatCompletionRequest = {
|
|
25
|
+
/**
|
|
26
|
+
* The app identifier should be your app's URL and is used as the primary identifier for rankings.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* This is used to track API usage per application.
|
|
30
|
+
*/
|
|
31
|
+
httpReferer?: string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
*/
|
|
37
|
+
appTitle?: string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
*/
|
|
43
|
+
appCategories?: string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The intern to talk to.
|
|
46
|
+
*/
|
|
47
|
+
internId: string;
|
|
48
|
+
internChatCompletionRequest: models.InternChatCompletionRequest;
|
|
49
|
+
};
|
|
50
|
+
/** @internal */
|
|
51
|
+
export type CreateInternChatCompletionRequest$Outbound = {
|
|
52
|
+
"HTTP-Referer"?: string | undefined;
|
|
53
|
+
appTitle?: string | undefined;
|
|
54
|
+
appCategories?: string | undefined;
|
|
55
|
+
internId: string;
|
|
56
|
+
InternChatCompletionRequest: models.InternChatCompletionRequest$Outbound;
|
|
57
|
+
};
|
|
58
|
+
/** @internal */
|
|
59
|
+
export declare const CreateInternChatCompletionRequest$outboundSchema: z.ZodType<CreateInternChatCompletionRequest$Outbound, CreateInternChatCompletionRequest>;
|
|
60
|
+
export declare function createInternChatCompletionRequestToJSON(createInternChatCompletionRequest: CreateInternChatCompletionRequest): string;
|
|
61
|
+
//# sourceMappingURL=createinternchatcompletion.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 0d92e801a635
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod/v4";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import * as models from "../index.js";
|
|
8
|
+
/** @internal */
|
|
9
|
+
export const CreateInternChatCompletionRequest$outboundSchema = z.object({
|
|
10
|
+
httpReferer: z.string().optional(),
|
|
11
|
+
appTitle: z.string().optional(),
|
|
12
|
+
appCategories: z.string().optional(),
|
|
13
|
+
internId: z.string(),
|
|
14
|
+
internChatCompletionRequest: models.InternChatCompletionRequest$outboundSchema,
|
|
15
|
+
}).transform((v) => {
|
|
16
|
+
return remap$(v, {
|
|
17
|
+
httpReferer: "HTTP-Referer",
|
|
18
|
+
internChatCompletionRequest: "InternChatCompletionRequest",
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
export function createInternChatCompletionRequestToJSON(createInternChatCompletionRequest) {
|
|
22
|
+
return JSON.stringify(CreateInternChatCompletionRequest$outboundSchema.parse(createInternChatCompletionRequest));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=createinternchatcompletion.js.map
|
|
@@ -14,6 +14,7 @@ export * from "./createembeddings.js";
|
|
|
14
14
|
export * from "./createguardrail.js";
|
|
15
15
|
export * from "./createimages.js";
|
|
16
16
|
export * from "./createintern.js";
|
|
17
|
+
export * from "./createinternchatcompletion.js";
|
|
17
18
|
export * from "./createkeys.js";
|
|
18
19
|
export * from "./createoauthtoken.js";
|
|
19
20
|
export * from "./createobservabilitydestination.js";
|
|
@@ -18,6 +18,7 @@ export * from "./createembeddings.js";
|
|
|
18
18
|
export * from "./createguardrail.js";
|
|
19
19
|
export * from "./createimages.js";
|
|
20
20
|
export * from "./createintern.js";
|
|
21
|
+
export * from "./createinternchatcompletion.js";
|
|
21
22
|
export * from "./createkeys.js";
|
|
22
23
|
export * from "./createoauthtoken.js";
|
|
23
24
|
export * from "./createobservabilitydestination.js";
|
package/esm/sdk/interns.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EventStream } from "../lib/event-streams.js";
|
|
1
2
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
2
3
|
import * as models from "../models/index.js";
|
|
3
4
|
import * as operations from "../models/operations/index.js";
|
|
@@ -51,5 +52,24 @@ export declare class Interns extends ClientSDK {
|
|
|
51
52
|
* Stops the intern runtime while keeping its disk and configuration for a later provision call. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.
|
|
52
53
|
*/
|
|
53
54
|
suspendIntern(request: operations.SuspendInternRequest, options?: RequestOptions): Promise<models.SuspendInternResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Stream a chat completion with an intern
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* Sends a prompt to one of your interns and streams the reply as OpenAI-compatible server-sent events ending with `[DONE]`. The run executes on the intern, which may pause to ask you something. It then streams one `openrouter.provide_input` tool call and finishes with `finish_reason: "tool_calls"`, and the run stays open on the intern.
|
|
60
|
+
*
|
|
61
|
+
* Every response, whether it ends with `stop`, `tool_calls` or `error`, is followed by a final chunk with empty `choices` that carries `session_id`, then `data: [DONE]`. That chunk carries the `usage` the intern reported for the run, after `stop` or `error`, and `null` when the intern reported none. After `tool_calls` its `usage` is `null` because the turn is not over. Read through `[DONE]`: the `session_id` you need to reply arrives after the `tool_calls` finish chunk.
|
|
62
|
+
*
|
|
63
|
+
* To answer, send a second request with the same `session_id`, the assistant message echoing that tool call, and a `tool` message whose `tool_call_id` is the tool call id and whose `content` is the answer. The answer is delivered to the run that asked and the stream continues from where it paused. A question stays open for its interaction deadline (5 minutes by default) and the run is cancelled when that passes. Rejected replies do not extend the deadline.
|
|
64
|
+
*
|
|
65
|
+
* Closing the connection after the `[DONE]` that follows `finish_reason: "tool_calls"` keeps the run alive. Disconnecting while a response is still streaming cancels the run. The disconnect is noticed when the intern next writes to the stream, which during a silent tool run can take more than one 30 second heartbeat interval.
|
|
66
|
+
*
|
|
67
|
+
* A run the intern ends while you are still connected, by cancellation or by a deadline, ends the stream with a `finish_reason: "error"` chunk carrying `410` and reason `run_ended`, then the final empty-`choices` chunk and `[DONE]`. That error reports only an ending the intern confirmed. A connection that breaks without that confirmation ends with reason `stream_severed`, and a client that has already disconnected is promised no final event.
|
|
68
|
+
*
|
|
69
|
+
* Set `approval_mode` to `manual` to have the intern ask before approval-bearing tools such as the shell. Omitted, the run self-drives and consents on your behalf. The mode belongs to the run started by that prompt and must be repeated on later prompts.
|
|
70
|
+
*
|
|
71
|
+
* Available to interns programme members. Callers outside the programme receive `404` for every path under `/api/v1/interns`.
|
|
72
|
+
*/
|
|
73
|
+
chat(request: operations.CreateInternChatCompletionRequest, options?: RequestOptions): Promise<EventStream<models.InternChatCompletionChunk>>;
|
|
54
74
|
}
|
|
55
75
|
//# sourceMappingURL=interns.d.ts.map
|
package/esm/sdk/interns.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
* @generated-id: fc3b4e6c5008
|
|
4
4
|
*/
|
|
5
|
+
import { internsChat } from "../funcs/internsChat.js";
|
|
5
6
|
import { internsCreateIntern } from "../funcs/internsCreateIntern.js";
|
|
6
7
|
import { internsDeleteIntern } from "../funcs/internsDeleteIntern.js";
|
|
7
8
|
import { internsGetIntern } from "../funcs/internsGetIntern.js";
|
|
@@ -75,5 +76,26 @@ export class Interns extends ClientSDK {
|
|
|
75
76
|
async suspendIntern(request, options) {
|
|
76
77
|
return unwrapAsync(internsSuspendIntern(this, request, options));
|
|
77
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Stream a chat completion with an intern
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Sends a prompt to one of your interns and streams the reply as OpenAI-compatible server-sent events ending with `[DONE]`. The run executes on the intern, which may pause to ask you something. It then streams one `openrouter.provide_input` tool call and finishes with `finish_reason: "tool_calls"`, and the run stays open on the intern.
|
|
84
|
+
*
|
|
85
|
+
* Every response, whether it ends with `stop`, `tool_calls` or `error`, is followed by a final chunk with empty `choices` that carries `session_id`, then `data: [DONE]`. That chunk carries the `usage` the intern reported for the run, after `stop` or `error`, and `null` when the intern reported none. After `tool_calls` its `usage` is `null` because the turn is not over. Read through `[DONE]`: the `session_id` you need to reply arrives after the `tool_calls` finish chunk.
|
|
86
|
+
*
|
|
87
|
+
* To answer, send a second request with the same `session_id`, the assistant message echoing that tool call, and a `tool` message whose `tool_call_id` is the tool call id and whose `content` is the answer. The answer is delivered to the run that asked and the stream continues from where it paused. A question stays open for its interaction deadline (5 minutes by default) and the run is cancelled when that passes. Rejected replies do not extend the deadline.
|
|
88
|
+
*
|
|
89
|
+
* Closing the connection after the `[DONE]` that follows `finish_reason: "tool_calls"` keeps the run alive. Disconnecting while a response is still streaming cancels the run. The disconnect is noticed when the intern next writes to the stream, which during a silent tool run can take more than one 30 second heartbeat interval.
|
|
90
|
+
*
|
|
91
|
+
* A run the intern ends while you are still connected, by cancellation or by a deadline, ends the stream with a `finish_reason: "error"` chunk carrying `410` and reason `run_ended`, then the final empty-`choices` chunk and `[DONE]`. That error reports only an ending the intern confirmed. A connection that breaks without that confirmation ends with reason `stream_severed`, and a client that has already disconnected is promised no final event.
|
|
92
|
+
*
|
|
93
|
+
* Set `approval_mode` to `manual` to have the intern ask before approval-bearing tools such as the shell. Omitted, the run self-drives and consents on your behalf. The mode belongs to the run started by that prompt and must be repeated on later prompts.
|
|
94
|
+
*
|
|
95
|
+
* Available to interns programme members. Callers outside the programme receive `404` for every path under `/api/v1/interns`.
|
|
96
|
+
*/
|
|
97
|
+
async chat(request, options) {
|
|
98
|
+
return unwrapAsync(internsChat(this, request, options));
|
|
99
|
+
}
|
|
78
100
|
}
|
|
79
101
|
//# sourceMappingURL=interns.js.map
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrouter/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.137",
|
|
4
4
|
"author": "OpenRouter",
|
|
5
5
|
"description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 400+ language models through a unified API.",
|
|
6
6
|
"keywords": [
|
|
@@ -73,14 +73,14 @@
|
|
|
73
73
|
"lint": "eslint --cache --max-warnings=0 src",
|
|
74
74
|
"build": "tsc",
|
|
75
75
|
"prepublishOnly": "npm run build",
|
|
76
|
-
"
|
|
76
|
+
"compile": "tsc",
|
|
77
77
|
"prepare": "npm run build",
|
|
78
|
-
"test:e2e": "vitest --run --project e2e",
|
|
79
78
|
"test:transit": "exit 0",
|
|
80
79
|
"test:watch": "vitest --watch --project unit",
|
|
81
|
-
"
|
|
82
|
-
"compile": "tsc",
|
|
80
|
+
"postinstall": "node scripts/check-types.js || true",
|
|
83
81
|
"test": "vitest --run --project unit",
|
|
82
|
+
"test:e2e": "vitest --run --project e2e",
|
|
83
|
+
"typecheck": "tsc --noEmit",
|
|
84
84
|
"typecheck:transit": "exit 0"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {},
|