core: expose v2 model listing API (#25821)

This commit is contained in:
Dax
2026-05-13 10:43:08 -04:00
committed by GitHub
parent bebe5442a5
commit 8345152319
138 changed files with 8191 additions and 305 deletions

View File

@@ -197,6 +197,7 @@ import type {
TuiSelectSessionResponses,
TuiShowToastResponses,
TuiSubmitPromptResponses,
V2ModelListResponses,
V2SessionCompactResponses,
V2SessionContextResponses,
V2SessionListErrors,
@@ -4375,11 +4376,48 @@ export class Session3 extends HeyApiClient {
}
}
export class Model extends HeyApiClient {
/**
* List v2 models
*
* Retrieve available v2 models ordered by release date.
*/
public list<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<V2ModelListResponses, unknown, ThrowOnError>({
url: "/api/model",
...options,
...params,
})
}
}
export class V2 extends HeyApiClient {
private _session?: Session3
get session(): Session3 {
return (this._session ??= new Session3({ client: this.client }))
}
private _model?: Model
get model(): Model {
return (this._model ??= new Model({ client: this.client }))
}
}
export class Control extends HeyApiClient {

View File

@@ -3378,6 +3378,78 @@ export type SessionMessage =
| SessionMessageAssistant
| SessionMessageCompaction
export type ModelV2Info = {
id: string
providerID: string
family?: string
name: string
endpoint:
| {
type: "openai/responses"
url: string
websocket?: boolean
}
| {
type: "openai/completions"
url: string
reasoning?:
| {
type: "reasoning_content"
}
| {
type: "reasoning_details"
}
}
| {
type: "anthropic/messages"
url: string
}
capabilities: {
tools: boolean
input: Array<string>
output: Array<string>
}
options: {
headers: {
[key: string]: string
}
body: {
[key: string]: unknown
}
variant?: string
}
variants: Array<{
id: string
headers: {
[key: string]: string
}
body: {
[key: string]: unknown
}
}>
time: {
released: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
}
cost: Array<{
tier?: {
type: "context"
size: number
}
input: number
output: number
cache: {
read: number
write: number
}
}>
status: "alpha" | "beta" | "deprecated" | "active"
limit: {
context: number
input?: number
output: number
}
}
export type EventTuiToastShow1 = {
id: string
type: "tui.toast.show"
@@ -6505,6 +6577,25 @@ export type V2SessionMessagesResponses = {
export type V2SessionMessagesResponse2 = V2SessionMessagesResponses[keyof V2SessionMessagesResponses]
export type V2ModelListData = {
body?: never
path?: never
query?: {
directory?: string
workspace?: string
}
url: "/api/model"
}
export type V2ModelListResponses = {
/**
* Success
*/
200: Array<ModelV2Info>
}
export type V2ModelListResponse = V2ModelListResponses[keyof V2ModelListResponses]
export type TuiAppendPromptData = {
body?: {
text: string