@standardagents/deepinfra 0.0.1-dev.fffff

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/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @standardagents/deepinfra
2
+
3
+ First-party [DeepInfra](https://deepinfra.com/) provider for Standard Agents.
4
+
5
+ ```bash
6
+ pnpm add @standardagents/deepinfra
7
+ ```
8
+
9
+ ```ts
10
+ import { defineModel } from '@standardagents/builder';
11
+ import { deepinfra } from '@standardagents/deepinfra';
12
+
13
+ export default defineModel({
14
+ name: 'deepinfra-chat',
15
+ provider: deepinfra,
16
+ model: 'deepseek-ai/DeepSeek-V3',
17
+ });
18
+ ```
19
+
20
+ Set `DEEPINFRA_API_KEY` for direct BYOK requests. The provider uses DeepInfra's OpenAI-compatible Chat Completions endpoint, discovers chat models and per-million-token prices from the live public catalog, supports streaming, images, tools, strict structured output, reasoning controls, prompt caching options, and request inspection, and preserves DeepInfra's response-level `usage.estimated_cost` as `usage.cost`.
21
+
22
+ Model discovery also resolves the model namespace (for example `deepseek-ai`, `meta-llama`, or `Qwen`) to bundled local lab artwork, so Builder model lists show the model creator rather than repeating the DeepInfra provider mark.
23
+
24
+ Connection slots are `apiKey`, `baseUrl` (default `https://api.deepinfra.com/v1/openai`), `modelsUrl` (default `https://api.deepinfra.com/v1/models`), and `timeout`.
25
+
26
+ See the [DeepInfra provider guide](https://docs.standardagentbuilder.com/providers/deepinfra) and [DeepInfra API docs](https://docs.deepinfra.com/chat/overview).
@@ -0,0 +1,93 @@
1
+ import { LLMProviderInterface, ProviderFactoryConfig, ModelCapabilities, ProviderModelInfo, ProviderRequest, ProviderResponse, ProviderStreamChunk, InspectedRequest, ProviderUsagePricing, ProviderUsage, ProviderFactoryWithOptions } from '@standardagents/spec';
2
+ import { z } from 'zod';
3
+
4
+ /** DeepInfra-specific and OpenAI-compatible Chat Completions options. */
5
+ declare const deepinfraProviderOptions: z.ZodObject<{
6
+ n: z.ZodOptional<z.ZodNumber>;
7
+ seed: z.ZodOptional<z.ZodNumber>;
8
+ frequency_penalty: z.ZodOptional<z.ZodNumber>;
9
+ presence_penalty: z.ZodOptional<z.ZodNumber>;
10
+ repetition_penalty: z.ZodOptional<z.ZodNumber>;
11
+ top_k: z.ZodOptional<z.ZodNumber>;
12
+ min_p: z.ZodOptional<z.ZodNumber>;
13
+ logit_bias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
14
+ logprobs: z.ZodOptional<z.ZodBoolean>;
15
+ top_logprobs: z.ZodOptional<z.ZodNumber>;
16
+ stop_token_ids: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
17
+ reasoning_effort: z.ZodOptional<z.ZodEnum<{
18
+ none: "none";
19
+ low: "low";
20
+ medium: "medium";
21
+ high: "high";
22
+ }>>;
23
+ reasoning: z.ZodOptional<z.ZodObject<{
24
+ enabled: z.ZodOptional<z.ZodBoolean>;
25
+ effort: z.ZodOptional<z.ZodEnum<{
26
+ none: "none";
27
+ low: "low";
28
+ medium: "medium";
29
+ high: "high";
30
+ }>>;
31
+ }, z.core.$loose>>;
32
+ service_tier: z.ZodOptional<z.ZodEnum<{
33
+ default: "default";
34
+ priority: "priority";
35
+ flex: "flex";
36
+ }>>;
37
+ prompt_cache_key: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$loose>;
39
+ type DeepInfraProviderOptions = z.infer<typeof deepinfraProviderOptions>;
40
+
41
+ interface DeepInfraModelInfo {
42
+ id: string;
43
+ object?: string;
44
+ created?: number;
45
+ owned_by?: string;
46
+ metadata?: {
47
+ description?: string;
48
+ context_length?: number;
49
+ max_tokens?: number;
50
+ pricing?: {
51
+ input_tokens?: number;
52
+ output_tokens?: number;
53
+ cache_read_tokens?: number;
54
+ };
55
+ tags?: string[];
56
+ };
57
+ }
58
+ declare function normalizeDeepInfraPricePerMillion(value: unknown): number | undefined;
59
+ declare function deepinfraUsagePricingFromModel(model: DeepInfraModelInfo | undefined): ProviderUsagePricing | undefined;
60
+ declare function calculateDeepInfraUsageCost(usage: ProviderUsage, pricing?: ProviderUsagePricing): number | undefined;
61
+ declare class DeepInfraProvider implements LLMProviderInterface {
62
+ readonly name = "deepinfra";
63
+ readonly specificationVersion: "1";
64
+ private config;
65
+ private modelsCache;
66
+ private modelsCacheTime;
67
+ private static readonly CACHE_TTL;
68
+ constructor(config: ProviderFactoryConfig);
69
+ supportsModel(_modelId: string): boolean;
70
+ getIcon(modelId?: string): string;
71
+ private baseUrl;
72
+ private modelsUrl;
73
+ private fetch;
74
+ private headers;
75
+ private requestGuard;
76
+ private fetchModelsWithCache;
77
+ private mapModelCapabilities;
78
+ getModelCapabilities(modelId: string): Promise<ModelCapabilities | null>;
79
+ private mapToProviderModelInfo;
80
+ getModels(filter?: string): Promise<ProviderModelInfo[]>;
81
+ private getUsagePricing;
82
+ generate(request: ProviderRequest): Promise<ProviderResponse>;
83
+ stream(request: ProviderRequest): Promise<AsyncIterable<ProviderStreamChunk>>;
84
+ private toHttpProviderErrorFromResponse;
85
+ private toProviderError;
86
+ private toHttpProviderError;
87
+ inspectRequest(request: ProviderRequest): Promise<InspectedRequest>;
88
+ }
89
+
90
+ /** DeepInfra provider factory backed by its OpenAI-compatible chat API and live model catalog. */
91
+ declare const deepinfra: ProviderFactoryWithOptions<typeof deepinfraProviderOptions>;
92
+
93
+ export { type DeepInfraModelInfo, DeepInfraProvider, type DeepInfraProviderOptions, calculateDeepInfraUsageCost, deepinfra, deepinfraProviderOptions, deepinfraUsagePricingFromModel, normalizeDeepInfraPricePerMillion };