@onlist/sdk 0.1.0 → 0.2.0

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/dist/index.d.cts CHANGED
@@ -1,21 +1,25 @@
1
1
  import OpenAI, { ClientOptions } from 'openai';
2
2
 
3
+ /** Model pricing in USD per million tokens. */
3
4
  interface Pricing {
4
5
  prompt: string;
5
6
  completion: string;
6
7
  request?: string | null;
7
8
  }
9
+ /** Model architecture metadata. */
8
10
  interface Architecture {
9
11
  modality?: string | null;
10
12
  input_modalities?: string[] | null;
11
13
  output_modalities?: string[] | null;
12
14
  tokenizer?: string | null;
13
15
  }
16
+ /** Top-provider context limits for a model. */
14
17
  interface TopProvider {
15
18
  context_length?: number | null;
16
19
  max_completion_tokens?: number | null;
17
20
  is_moderated?: boolean | null;
18
21
  }
22
+ /** A model listed in the marketplace catalog. */
19
23
  interface Model {
20
24
  id: string;
21
25
  name?: string | null;
@@ -32,8 +36,8 @@ interface Model {
32
36
  quantization?: string | null;
33
37
  top_provider?: TopProvider | null;
34
38
  is_ready?: boolean | null;
35
- [key: string]: unknown;
36
39
  }
40
+ /** A provider's offer for a specific model. */
37
41
  interface ProviderOffer {
38
42
  listing_id?: number | null;
39
43
  provider_id?: number | null;
@@ -44,8 +48,8 @@ interface ProviderOffer {
44
48
  price_input_usd?: string | null;
45
49
  price_output_usd?: string | null;
46
50
  availability_7d?: number | null;
47
- [key: string]: unknown;
48
51
  }
52
+ /** Detailed model info including all provider offers. */
49
53
  interface ModelDetail {
50
54
  id: string;
51
55
  name?: string | null;
@@ -57,8 +61,8 @@ interface ModelDetail {
57
61
  pricing?: Pricing | null;
58
62
  description?: string | null;
59
63
  providers: ProviderOffer[];
60
- [key: string]: unknown;
61
64
  }
65
+ /** Paginated list of models. */
62
66
  interface ModelListResponse {
63
67
  data: Model[];
64
68
  total?: number | null;
@@ -66,6 +70,7 @@ interface ModelListResponse {
66
70
  limit?: number | null;
67
71
  }
68
72
 
73
+ /** A provider (seller) on the marketplace. */
69
74
  interface Provider {
70
75
  id?: number | null;
71
76
  slug: string;
@@ -79,59 +84,159 @@ interface Provider {
79
84
  sample_count?: number | null;
80
85
  max_rpm?: number | null;
81
86
  availability_7d?: number | null;
82
- [key: string]: unknown;
83
87
  }
88
+ /** Detailed provider info including their listings. */
84
89
  interface ProviderDetail extends Provider {
85
90
  listings: Record<string, unknown>[];
86
91
  }
92
+ /** Paginated list of providers. */
87
93
  interface ProviderListResponse {
88
94
  items: Provider[];
89
95
  }
90
96
 
97
+ /** A single entry in the model usage leaderboard. */
98
+ interface ModelRanking {
99
+ rank: number;
100
+ model_name: string;
101
+ author: string;
102
+ author_icon: string | null;
103
+ total_tokens: string;
104
+ total_requests: number;
105
+ growth_pct: number | null;
106
+ }
107
+ /** A single data point in the model usage chart series. */
108
+ interface ModelSeriesPoint {
109
+ bucket: string;
110
+ value: number;
111
+ type: string;
112
+ }
113
+ /** Response from GET /api/mkt/rankings/models. */
114
+ interface ModelRankingsResponse {
115
+ leaderboard: ModelRanking[];
116
+ series: ModelSeriesPoint[];
117
+ top_models: string[];
118
+ sort: string;
119
+ window: string;
120
+ start_date: string;
121
+ end_date: string;
122
+ }
123
+ /** Query parameters for the model rankings endpoint. */
124
+ interface ModelRankingsParams {
125
+ sort?: "popular" | "trending";
126
+ window?: "day" | "week" | "month";
127
+ limit?: number;
128
+ offset?: number;
129
+ }
130
+ /** A single entry in the app rankings list. */
131
+ interface AppRanking {
132
+ app_id: number;
133
+ url_key: string;
134
+ slug: string | null;
135
+ title: string;
136
+ description: string | null;
137
+ domain: string;
138
+ icon_url: string | null;
139
+ categories: string[];
140
+ rank: number;
141
+ total_requests: number;
142
+ total_tokens: string;
143
+ growth_pct: number | null;
144
+ }
145
+ /** Response from GET /api/mkt/apps. */
146
+ interface AppRankingsResponse {
147
+ apps: AppRanking[];
148
+ page: number;
149
+ limit: number;
150
+ has_more: boolean;
151
+ sort: string;
152
+ window: string;
153
+ start_date: string;
154
+ end_date: string;
155
+ }
156
+ /** Query parameters for the app rankings endpoint. */
157
+ interface AppRankingsParams {
158
+ sort?: "popular" | "trending";
159
+ window?: "day" | "week" | "month";
160
+ category?: string;
161
+ subcategory?: string;
162
+ page?: number;
163
+ limit?: number;
164
+ }
165
+
166
+ /** Options for creating a Marketplace client. */
91
167
  interface MarketplaceOptions {
92
168
  apiKey?: string | null;
93
169
  baseURL: string;
94
170
  timeout?: number;
171
+ /** Maximum retry attempts for failed requests. Defaults to 2. */
172
+ maxRetries?: number;
95
173
  }
174
+ /** Access to marketplace model data. */
96
175
  declare class MarketplaceModels {
97
176
  private readonly _opts;
98
177
  constructor(_opts: MarketplaceOptions);
178
+ /** List models in the marketplace catalog. */
99
179
  list(params?: {
100
180
  limit?: number;
101
181
  offset?: number;
102
182
  q?: string;
103
183
  }): Promise<ModelListResponse>;
184
+ /** Get detailed info for a specific model, including provider offers. */
104
185
  get(modelId: string): Promise<ModelDetail>;
105
- private _fetch;
106
186
  }
187
+ /** Access to marketplace provider data. */
107
188
  declare class MarketplaceProviders {
108
189
  private readonly _opts;
109
190
  constructor(_opts: MarketplaceOptions);
191
+ /** List providers on the marketplace. */
110
192
  list(params?: {
111
193
  sort?: string;
112
194
  q?: string;
113
195
  }): Promise<ProviderListResponse>;
196
+ /** Get detailed info for a specific provider. */
114
197
  get(slug: string): Promise<ProviderDetail>;
115
- private _fetch;
116
198
  }
199
+ /** Access to marketplace rankings (models and apps). */
200
+ declare class MarketplaceRankings {
201
+ private readonly _opts;
202
+ constructor(_opts: MarketplaceOptions);
203
+ /** Get the model usage leaderboard and chart series. */
204
+ models(params?: ModelRankingsParams): Promise<ModelRankingsResponse>;
205
+ /** Get the app rankings list. */
206
+ apps(params?: AppRankingsParams): Promise<AppRankingsResponse>;
207
+ }
208
+ /** Client for the Onlist marketplace public API. */
117
209
  declare class Marketplace {
210
+ /** Browse and search models. */
118
211
  readonly models: MarketplaceModels;
212
+ /** Browse and search providers. */
119
213
  readonly providers: MarketplaceProviders;
214
+ /** Model and app usage rankings. */
215
+ readonly rankings: MarketplaceRankings;
120
216
  constructor(opts: MarketplaceOptions);
121
217
  }
122
218
 
219
+ /** Options for creating an Onlist client. */
123
220
  interface OnlistOptions extends Omit<ClientOptions, "apiKey" | "baseURL"> {
221
+ /** API key. Falls back to ONLIST_API_KEY then OPENAI_API_KEY env vars. */
124
222
  apiKey?: string | null;
223
+ /** Base URL for the API. Defaults to https://onlist.io/v1. */
125
224
  baseURL?: string | null;
225
+ /** Maximum retry attempts for marketplace API calls. Defaults to 2. */
226
+ maxRetries?: number;
126
227
  }
228
+ /** Onlist API client, extending the OpenAI SDK with marketplace features. */
127
229
  declare class Onlist extends OpenAI {
230
+ /** Access to marketplace data: models, providers, and rankings. */
128
231
  readonly marketplace: Marketplace;
129
232
  constructor(opts?: OnlistOptions);
130
233
  }
131
234
 
235
+ /** Base error class for all Onlist SDK errors. */
132
236
  declare class OnlistError extends Error {
133
237
  constructor(message: string);
134
238
  }
239
+ /** Error thrown when an API request fails. */
135
240
  declare class APIError extends OnlistError {
136
241
  readonly status: number;
137
242
  readonly type: string | null;
@@ -146,23 +251,33 @@ declare class APIError extends OnlistError {
146
251
  body?: unknown;
147
252
  });
148
253
  }
254
+ /** Error thrown when the API key is invalid or missing. */
149
255
  declare class AuthenticationError extends APIError {
150
256
  constructor(message?: string, opts?: Partial<ConstructorParameters<typeof APIError>[1]>);
151
257
  }
258
+ /** Error thrown when the account balance is insufficient. */
152
259
  declare class InsufficientBalanceError extends APIError {
153
260
  constructor(message?: string, opts?: Partial<ConstructorParameters<typeof APIError>[1]>);
154
261
  }
262
+ /** Error thrown when the request is rate-limited. */
155
263
  declare class RateLimitError extends APIError {
156
264
  constructor(message?: string, opts?: Partial<ConstructorParameters<typeof APIError>[1]>);
157
265
  }
266
+ /** Error thrown when no matching provider is available. */
158
267
  declare class ProviderError extends APIError {
159
268
  constructor(message: string, opts: ConstructorParameters<typeof APIError>[1]);
160
269
  }
270
+ /** Error thrown when a requested resource is not found. */
271
+ declare class NotFoundError extends APIError {
272
+ constructor(message?: string, opts?: Partial<ConstructorParameters<typeof APIError>[1]>);
273
+ }
161
274
 
275
+ /** Maximum price limits per token type (USD per million tokens). */
162
276
  interface MaxPrice {
163
277
  prompt?: number;
164
278
  completion?: number;
165
279
  }
280
+ /** Provider routing configuration for the Onlist marketplace. */
166
281
  interface ProviderRouting {
167
282
  only?: string[];
168
283
  sort?: "price" | "throughput";
@@ -173,6 +288,13 @@ interface ProviderRouting {
173
288
  max_price?: MaxPrice;
174
289
  }
175
290
 
176
- declare const VERSION = "0.1.0";
291
+ declare module "openai/resources/chat/completions/completions" {
292
+ interface ChatCompletionCreateParamsBase {
293
+ /** Onlist provider routing configuration. */
294
+ provider?: ProviderRouting;
295
+ }
296
+ }
297
+
298
+ declare const VERSION = "0.2.0";
177
299
 
178
- export { APIError, type Architecture, AuthenticationError, InsufficientBalanceError, Marketplace, MarketplaceModels, type MarketplaceOptions, MarketplaceProviders, type MaxPrice, type Model, type ModelDetail, type ModelListResponse, Onlist, OnlistError, type OnlistOptions, type Pricing, type Provider, type ProviderDetail, ProviderError, type ProviderListResponse, type ProviderOffer, type ProviderRouting, RateLimitError, type TopProvider, VERSION };
300
+ export { APIError, type AppRanking, type AppRankingsParams, type AppRankingsResponse, type Architecture, AuthenticationError, InsufficientBalanceError, Marketplace, MarketplaceModels, type MarketplaceOptions, MarketplaceProviders, MarketplaceRankings, type MaxPrice, type Model, type ModelDetail, type ModelListResponse, type ModelRanking, type ModelRankingsParams, type ModelRankingsResponse, type ModelSeriesPoint, NotFoundError, Onlist, OnlistError, type OnlistOptions, type Pricing, type Provider, type ProviderDetail, ProviderError, type ProviderListResponse, type ProviderOffer, type ProviderRouting, RateLimitError, type TopProvider, VERSION };
package/dist/index.d.ts CHANGED
@@ -1,21 +1,25 @@
1
1
  import OpenAI, { ClientOptions } from 'openai';
2
2
 
3
+ /** Model pricing in USD per million tokens. */
3
4
  interface Pricing {
4
5
  prompt: string;
5
6
  completion: string;
6
7
  request?: string | null;
7
8
  }
9
+ /** Model architecture metadata. */
8
10
  interface Architecture {
9
11
  modality?: string | null;
10
12
  input_modalities?: string[] | null;
11
13
  output_modalities?: string[] | null;
12
14
  tokenizer?: string | null;
13
15
  }
16
+ /** Top-provider context limits for a model. */
14
17
  interface TopProvider {
15
18
  context_length?: number | null;
16
19
  max_completion_tokens?: number | null;
17
20
  is_moderated?: boolean | null;
18
21
  }
22
+ /** A model listed in the marketplace catalog. */
19
23
  interface Model {
20
24
  id: string;
21
25
  name?: string | null;
@@ -32,8 +36,8 @@ interface Model {
32
36
  quantization?: string | null;
33
37
  top_provider?: TopProvider | null;
34
38
  is_ready?: boolean | null;
35
- [key: string]: unknown;
36
39
  }
40
+ /** A provider's offer for a specific model. */
37
41
  interface ProviderOffer {
38
42
  listing_id?: number | null;
39
43
  provider_id?: number | null;
@@ -44,8 +48,8 @@ interface ProviderOffer {
44
48
  price_input_usd?: string | null;
45
49
  price_output_usd?: string | null;
46
50
  availability_7d?: number | null;
47
- [key: string]: unknown;
48
51
  }
52
+ /** Detailed model info including all provider offers. */
49
53
  interface ModelDetail {
50
54
  id: string;
51
55
  name?: string | null;
@@ -57,8 +61,8 @@ interface ModelDetail {
57
61
  pricing?: Pricing | null;
58
62
  description?: string | null;
59
63
  providers: ProviderOffer[];
60
- [key: string]: unknown;
61
64
  }
65
+ /** Paginated list of models. */
62
66
  interface ModelListResponse {
63
67
  data: Model[];
64
68
  total?: number | null;
@@ -66,6 +70,7 @@ interface ModelListResponse {
66
70
  limit?: number | null;
67
71
  }
68
72
 
73
+ /** A provider (seller) on the marketplace. */
69
74
  interface Provider {
70
75
  id?: number | null;
71
76
  slug: string;
@@ -79,59 +84,159 @@ interface Provider {
79
84
  sample_count?: number | null;
80
85
  max_rpm?: number | null;
81
86
  availability_7d?: number | null;
82
- [key: string]: unknown;
83
87
  }
88
+ /** Detailed provider info including their listings. */
84
89
  interface ProviderDetail extends Provider {
85
90
  listings: Record<string, unknown>[];
86
91
  }
92
+ /** Paginated list of providers. */
87
93
  interface ProviderListResponse {
88
94
  items: Provider[];
89
95
  }
90
96
 
97
+ /** A single entry in the model usage leaderboard. */
98
+ interface ModelRanking {
99
+ rank: number;
100
+ model_name: string;
101
+ author: string;
102
+ author_icon: string | null;
103
+ total_tokens: string;
104
+ total_requests: number;
105
+ growth_pct: number | null;
106
+ }
107
+ /** A single data point in the model usage chart series. */
108
+ interface ModelSeriesPoint {
109
+ bucket: string;
110
+ value: number;
111
+ type: string;
112
+ }
113
+ /** Response from GET /api/mkt/rankings/models. */
114
+ interface ModelRankingsResponse {
115
+ leaderboard: ModelRanking[];
116
+ series: ModelSeriesPoint[];
117
+ top_models: string[];
118
+ sort: string;
119
+ window: string;
120
+ start_date: string;
121
+ end_date: string;
122
+ }
123
+ /** Query parameters for the model rankings endpoint. */
124
+ interface ModelRankingsParams {
125
+ sort?: "popular" | "trending";
126
+ window?: "day" | "week" | "month";
127
+ limit?: number;
128
+ offset?: number;
129
+ }
130
+ /** A single entry in the app rankings list. */
131
+ interface AppRanking {
132
+ app_id: number;
133
+ url_key: string;
134
+ slug: string | null;
135
+ title: string;
136
+ description: string | null;
137
+ domain: string;
138
+ icon_url: string | null;
139
+ categories: string[];
140
+ rank: number;
141
+ total_requests: number;
142
+ total_tokens: string;
143
+ growth_pct: number | null;
144
+ }
145
+ /** Response from GET /api/mkt/apps. */
146
+ interface AppRankingsResponse {
147
+ apps: AppRanking[];
148
+ page: number;
149
+ limit: number;
150
+ has_more: boolean;
151
+ sort: string;
152
+ window: string;
153
+ start_date: string;
154
+ end_date: string;
155
+ }
156
+ /** Query parameters for the app rankings endpoint. */
157
+ interface AppRankingsParams {
158
+ sort?: "popular" | "trending";
159
+ window?: "day" | "week" | "month";
160
+ category?: string;
161
+ subcategory?: string;
162
+ page?: number;
163
+ limit?: number;
164
+ }
165
+
166
+ /** Options for creating a Marketplace client. */
91
167
  interface MarketplaceOptions {
92
168
  apiKey?: string | null;
93
169
  baseURL: string;
94
170
  timeout?: number;
171
+ /** Maximum retry attempts for failed requests. Defaults to 2. */
172
+ maxRetries?: number;
95
173
  }
174
+ /** Access to marketplace model data. */
96
175
  declare class MarketplaceModels {
97
176
  private readonly _opts;
98
177
  constructor(_opts: MarketplaceOptions);
178
+ /** List models in the marketplace catalog. */
99
179
  list(params?: {
100
180
  limit?: number;
101
181
  offset?: number;
102
182
  q?: string;
103
183
  }): Promise<ModelListResponse>;
184
+ /** Get detailed info for a specific model, including provider offers. */
104
185
  get(modelId: string): Promise<ModelDetail>;
105
- private _fetch;
106
186
  }
187
+ /** Access to marketplace provider data. */
107
188
  declare class MarketplaceProviders {
108
189
  private readonly _opts;
109
190
  constructor(_opts: MarketplaceOptions);
191
+ /** List providers on the marketplace. */
110
192
  list(params?: {
111
193
  sort?: string;
112
194
  q?: string;
113
195
  }): Promise<ProviderListResponse>;
196
+ /** Get detailed info for a specific provider. */
114
197
  get(slug: string): Promise<ProviderDetail>;
115
- private _fetch;
116
198
  }
199
+ /** Access to marketplace rankings (models and apps). */
200
+ declare class MarketplaceRankings {
201
+ private readonly _opts;
202
+ constructor(_opts: MarketplaceOptions);
203
+ /** Get the model usage leaderboard and chart series. */
204
+ models(params?: ModelRankingsParams): Promise<ModelRankingsResponse>;
205
+ /** Get the app rankings list. */
206
+ apps(params?: AppRankingsParams): Promise<AppRankingsResponse>;
207
+ }
208
+ /** Client for the Onlist marketplace public API. */
117
209
  declare class Marketplace {
210
+ /** Browse and search models. */
118
211
  readonly models: MarketplaceModels;
212
+ /** Browse and search providers. */
119
213
  readonly providers: MarketplaceProviders;
214
+ /** Model and app usage rankings. */
215
+ readonly rankings: MarketplaceRankings;
120
216
  constructor(opts: MarketplaceOptions);
121
217
  }
122
218
 
219
+ /** Options for creating an Onlist client. */
123
220
  interface OnlistOptions extends Omit<ClientOptions, "apiKey" | "baseURL"> {
221
+ /** API key. Falls back to ONLIST_API_KEY then OPENAI_API_KEY env vars. */
124
222
  apiKey?: string | null;
223
+ /** Base URL for the API. Defaults to https://onlist.io/v1. */
125
224
  baseURL?: string | null;
225
+ /** Maximum retry attempts for marketplace API calls. Defaults to 2. */
226
+ maxRetries?: number;
126
227
  }
228
+ /** Onlist API client, extending the OpenAI SDK with marketplace features. */
127
229
  declare class Onlist extends OpenAI {
230
+ /** Access to marketplace data: models, providers, and rankings. */
128
231
  readonly marketplace: Marketplace;
129
232
  constructor(opts?: OnlistOptions);
130
233
  }
131
234
 
235
+ /** Base error class for all Onlist SDK errors. */
132
236
  declare class OnlistError extends Error {
133
237
  constructor(message: string);
134
238
  }
239
+ /** Error thrown when an API request fails. */
135
240
  declare class APIError extends OnlistError {
136
241
  readonly status: number;
137
242
  readonly type: string | null;
@@ -146,23 +251,33 @@ declare class APIError extends OnlistError {
146
251
  body?: unknown;
147
252
  });
148
253
  }
254
+ /** Error thrown when the API key is invalid or missing. */
149
255
  declare class AuthenticationError extends APIError {
150
256
  constructor(message?: string, opts?: Partial<ConstructorParameters<typeof APIError>[1]>);
151
257
  }
258
+ /** Error thrown when the account balance is insufficient. */
152
259
  declare class InsufficientBalanceError extends APIError {
153
260
  constructor(message?: string, opts?: Partial<ConstructorParameters<typeof APIError>[1]>);
154
261
  }
262
+ /** Error thrown when the request is rate-limited. */
155
263
  declare class RateLimitError extends APIError {
156
264
  constructor(message?: string, opts?: Partial<ConstructorParameters<typeof APIError>[1]>);
157
265
  }
266
+ /** Error thrown when no matching provider is available. */
158
267
  declare class ProviderError extends APIError {
159
268
  constructor(message: string, opts: ConstructorParameters<typeof APIError>[1]);
160
269
  }
270
+ /** Error thrown when a requested resource is not found. */
271
+ declare class NotFoundError extends APIError {
272
+ constructor(message?: string, opts?: Partial<ConstructorParameters<typeof APIError>[1]>);
273
+ }
161
274
 
275
+ /** Maximum price limits per token type (USD per million tokens). */
162
276
  interface MaxPrice {
163
277
  prompt?: number;
164
278
  completion?: number;
165
279
  }
280
+ /** Provider routing configuration for the Onlist marketplace. */
166
281
  interface ProviderRouting {
167
282
  only?: string[];
168
283
  sort?: "price" | "throughput";
@@ -173,6 +288,13 @@ interface ProviderRouting {
173
288
  max_price?: MaxPrice;
174
289
  }
175
290
 
176
- declare const VERSION = "0.1.0";
291
+ declare module "openai/resources/chat/completions/completions" {
292
+ interface ChatCompletionCreateParamsBase {
293
+ /** Onlist provider routing configuration. */
294
+ provider?: ProviderRouting;
295
+ }
296
+ }
297
+
298
+ declare const VERSION = "0.2.0";
177
299
 
178
- export { APIError, type Architecture, AuthenticationError, InsufficientBalanceError, Marketplace, MarketplaceModels, type MarketplaceOptions, MarketplaceProviders, type MaxPrice, type Model, type ModelDetail, type ModelListResponse, Onlist, OnlistError, type OnlistOptions, type Pricing, type Provider, type ProviderDetail, ProviderError, type ProviderListResponse, type ProviderOffer, type ProviderRouting, RateLimitError, type TopProvider, VERSION };
300
+ export { APIError, type AppRanking, type AppRankingsParams, type AppRankingsResponse, type Architecture, AuthenticationError, InsufficientBalanceError, Marketplace, MarketplaceModels, type MarketplaceOptions, MarketplaceProviders, MarketplaceRankings, type MaxPrice, type Model, type ModelDetail, type ModelListResponse, type ModelRanking, type ModelRankingsParams, type ModelRankingsResponse, type ModelSeriesPoint, NotFoundError, Onlist, OnlistError, type OnlistOptions, type Pricing, type Provider, type ProviderDetail, ProviderError, type ProviderListResponse, type ProviderOffer, type ProviderRouting, RateLimitError, type TopProvider, VERSION };