quantum-ai-sdk 0.4.0 → 0.5.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/README.md +174 -0
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +50 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# @quantum-encoding/quantum-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript client SDK for the [Quantum AI API](https://api.quantumencoding.ai).
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @quantum-encoding/quantum-sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { QuantumClient } from "@quantum-encoding/quantum-sdk";
|
|
13
|
+
|
|
14
|
+
const client = new QuantumClient("qai_k_your_key_here");
|
|
15
|
+
const response = await client.chat("gemini-2.5-flash", "Hello! What is quantum computing?");
|
|
16
|
+
console.log(response.text);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- 110+ endpoints across 10 AI providers and 45+ models
|
|
22
|
+
- TypeScript-first with full type definitions
|
|
23
|
+
- ESM + CommonJS dual package
|
|
24
|
+
- Streaming via async iterators
|
|
25
|
+
- Agent orchestration with SSE event streams
|
|
26
|
+
- GPU/CPU compute rental
|
|
27
|
+
- Batch processing (50% discount)
|
|
28
|
+
- Tree-shakeable exports
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
### Chat Completion
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { QuantumClient } from "@quantum-encoding/quantum-sdk";
|
|
36
|
+
|
|
37
|
+
const client = new QuantumClient("qai_k_your_key_here");
|
|
38
|
+
|
|
39
|
+
const response = await client.chat({
|
|
40
|
+
model: "claude-sonnet-4-6",
|
|
41
|
+
messages: [
|
|
42
|
+
{ role: "system", content: "You are a helpful assistant." },
|
|
43
|
+
{ role: "user", content: "Explain closures in JavaScript" },
|
|
44
|
+
],
|
|
45
|
+
temperature: 0.7,
|
|
46
|
+
maxTokens: 1000,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
console.log(response.text);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Streaming
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
const stream = client.chatStream({
|
|
56
|
+
model: "claude-sonnet-4-6",
|
|
57
|
+
messages: [{ role: "user", content: "Write a haiku about TypeScript" }],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
for await (const event of stream) {
|
|
61
|
+
if (event.deltaText) {
|
|
62
|
+
process.stdout.write(event.deltaText);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Image Generation
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const images = await client.generateImage("grok-imagine-image", "A cosmic duck in space");
|
|
71
|
+
for (const image of images.images) {
|
|
72
|
+
console.log(image.url ?? "base64");
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Text-to-Speech
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const audio = await client.speak("Welcome to Quantum AI!", "alloy", "mp3");
|
|
80
|
+
console.log(audio.audioUrl);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Web Search
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const results = await client.webSearch("latest TypeScript releases 2026");
|
|
87
|
+
for (const result of results.results) {
|
|
88
|
+
console.log(`${result.title}: ${result.url}`);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Agent Orchestration
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const stream = client.agentRun("Research quantum computing breakthroughs");
|
|
96
|
+
for await (const event of stream) {
|
|
97
|
+
switch (event.type) {
|
|
98
|
+
case "content_delta":
|
|
99
|
+
process.stdout.write(event.content ?? "");
|
|
100
|
+
break;
|
|
101
|
+
case "done":
|
|
102
|
+
console.log("\n--- Done ---");
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## All Endpoints
|
|
109
|
+
|
|
110
|
+
| Category | Endpoints | Description |
|
|
111
|
+
|----------|-----------|-------------|
|
|
112
|
+
| Chat | 2 | Text generation + session chat |
|
|
113
|
+
| Agent | 2 | Multi-step orchestration + missions |
|
|
114
|
+
| Images | 2 | Generation + editing |
|
|
115
|
+
| Video | 7 | Generation, studio, translation, avatars |
|
|
116
|
+
| Audio | 13 | TTS, STT, music, dialogue, dubbing, voice design |
|
|
117
|
+
| Voices | 5 | Clone, list, delete, library, design |
|
|
118
|
+
| Embeddings | 1 | Text embeddings |
|
|
119
|
+
| RAG | 4 | Vertex AI + SurrealDB search |
|
|
120
|
+
| Documents | 3 | Extract, chunk, process |
|
|
121
|
+
| Search | 3 | Web search, context, answers |
|
|
122
|
+
| Scanner | 11 | Code scanning, type queries, diffs |
|
|
123
|
+
| Scraper | 2 | Doc scraping + screenshots |
|
|
124
|
+
| Jobs | 3 | Async job management |
|
|
125
|
+
| Compute | 7 | GPU/CPU rental |
|
|
126
|
+
| Keys | 3 | API key management |
|
|
127
|
+
| Account | 3 | Balance, usage, summary |
|
|
128
|
+
| Credits | 6 | Packs, tiers, lifetime, purchase |
|
|
129
|
+
| Batch | 4 | 50% discount batch processing |
|
|
130
|
+
| Realtime | 3 | Voice sessions |
|
|
131
|
+
| Models | 2 | Model list + pricing |
|
|
132
|
+
|
|
133
|
+
## Authentication
|
|
134
|
+
|
|
135
|
+
Pass your API key when creating the client:
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
const client = new QuantumClient("qai_k_your_key_here");
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The SDK sends it as the `X-API-Key` header. Both `qai_...` (primary) and `qai_k_...` (scoped) keys are supported. You can also use `Authorization: Bearer <key>`.
|
|
142
|
+
|
|
143
|
+
Get your API key at [cosmicduck.dev](https://cosmicduck.dev).
|
|
144
|
+
|
|
145
|
+
## Pricing
|
|
146
|
+
|
|
147
|
+
See [api.quantumencoding.ai/pricing](https://api.quantumencoding.ai/pricing) for current rates.
|
|
148
|
+
|
|
149
|
+
The **Lifetime tier** offers 0% margin at-cost pricing via a one-time payment.
|
|
150
|
+
|
|
151
|
+
## Other SDKs
|
|
152
|
+
|
|
153
|
+
All SDKs are at v0.4.0 with type parity verified by scanner.
|
|
154
|
+
|
|
155
|
+
| Language | Package | Install |
|
|
156
|
+
|----------|---------|---------|
|
|
157
|
+
| Rust | quantum-sdk | `cargo add quantum-sdk` |
|
|
158
|
+
| Go | quantum-sdk | `go get github.com/quantum-encoding/quantum-sdk` |
|
|
159
|
+
| **TypeScript** | @quantum-encoding/quantum-sdk | `npm i @quantum-encoding/quantum-sdk` |
|
|
160
|
+
| Python | quantum-sdk | `pip install quantum-sdk` |
|
|
161
|
+
| Swift | QuantumSDK | Swift Package Manager |
|
|
162
|
+
| Kotlin | quantum-sdk | Gradle dependency |
|
|
163
|
+
|
|
164
|
+
MCP server: `npx @quantum-encoding/ai-conductor-mcp`
|
|
165
|
+
|
|
166
|
+
## API Reference
|
|
167
|
+
|
|
168
|
+
- Interactive docs: [api.quantumencoding.ai/docs](https://api.quantumencoding.ai/docs)
|
|
169
|
+
- OpenAPI spec: [api.quantumencoding.ai/openapi.yaml](https://api.quantumencoding.ai/openapi.yaml)
|
|
170
|
+
- LLM context: [api.quantumencoding.ai/llms.txt](https://api.quantumencoding.ai/llms.txt)
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { realtimeConnect, realtimeConnectDirect, realtimeSession, realtimeEnd, r
|
|
|
5
5
|
export type { RealtimeConfig, RealtimeEvent, RealtimeSession } from "./realtime.js";
|
|
6
6
|
export { contact } from "./contact.js";
|
|
7
7
|
export type { BillingRequest, BillingEntry, BillingResponse } from "./compute-billing.js";
|
|
8
|
-
export type { ClientOptions, ResponseMeta, ChatRequest, ChatMessage, ChatTool, ContentBlock, ChatUsage, ChatResponse, StreamEvent, StreamDelta, StreamToolUse, SessionChatRequest, SessionChatResponse, SessionToolResult, ContextConfig, ContextMetadata, AgentRequest, AgentWorkerConfig, AgentEvent, MissionRequest, MissionWorkerConfig, MissionEvent, ImageRequest, ImageResponse, GeneratedImage, ImageEditRequest, ImageEditResponse, TTSRequest, TTSResponse, STTRequest, STTResponse, MusicRequest, MusicClip, MusicResponse, SoundEffectRequest, SoundEffectResponse, DialogueRequest, DialogueResponse, DialogueVoice, SpeechToSpeechRequest, SpeechToSpeechResponse, IsolateVoiceRequest, IsolateVoiceResponse, RemixVoiceRequest, RemixVoiceResponse, DubRequest, DubResponse, AlignRequest, AlignResponse, AlignedWord, VoiceDesignRequest, VoiceDesignResponse, VoicePreview, StarfishTTSRequest, StarfishTTSResponse, VideoRequest, VideoResponse, GeneratedVideo, VideoStudioRequest, VideoTranslateRequest, PhotoAvatarRequest, DigitalTwinRequest, AsyncJobResponse, AvatarsResponse, HeyGenAvatar, HeyGenTemplatesResponse, HeyGenTemplate, HeyGenVoicesResponse, HeyGenVoice, EmbedRequest, EmbedResponse, DocumentRequest, DocumentResponse, ChunkDocumentRequest, ChunkDocumentResponse, DocumentChunk, ProcessDocumentRequest, ProcessDocumentResponse, RAGSearchRequest, RAGSearchResponse, RAGResult, RAGCorpus, SurrealRAGSearchRequest, SurrealRAGSearchResponse, SurrealRAGResult, SurrealRAGProvidersResponse, SurrealRAGProviderInfo, ModelInfo, PricingInfo, BalanceResponse, UsageEntry, UsageResponse, UsageQuery, UsageSummaryMonth, UsageSummaryResponse, PricingEntry, AccountPricingResponse, JobCreateRequest, JobCreateResponse, JobStatusResponse, JobListResponse, JobStreamEvent, JobListItem, CreateKeyRequest, CreateKeyResponse, KeyDetails, ListKeysResponse, ComputeTemplate, TemplatesResponse, ProvisionRequest, ProvisionResponse, ComputeInstanceInfo, InstancesResponse, InstanceDetailInfo, InstanceResponse, SSHKeyRequest, DeleteResponse, VoiceInfo, VoicesResponse, CloneVoiceRequest, CloneVoiceResponse, ContactRequest, BatchJobInput, BatchSubmitRequest, BatchSubmitResponse, BatchJsonlResponse, BatchJobInfo, BatchJobsResponse, CreditPack, CreditPacksResponse, CreditPurchaseRequest, CreditPurchaseResponse, CreditBalanceResponse, CreditTier, CreditTiersResponse, DevProgramApplyRequest, DevProgramApplyResponse, AuthUser, AuthResponse, AuthAppleRequest, WebSearchRequest, WebSearchResponse, WebSearchResult, NewsResult, VideoSearchResult, LLMContextRequest, LLMContextResponse, ContentChunk, ContextSource, SearchAnswerRequest, SearchAnswerResponse, SearchAnswerChoice, SearchCitation, StatusResponse, Citation, CollectionsListResponse, CollectionDocumentsResponse, CollectionSearchResponse, CreateCollectionRequest, DeleteCollectionResponse, ModelsResponse, RagCorporaResponse, Infobox, Discussion, TextToSpeechRequest, TextToSpeechResponse, SpeechToTextRequest, SpeechToTextResponse, ContactResponse, ContextChunk, ContextOptions, HeyGenAvatarsResponse, JobAcceptedResponse, JobListEntry, PostProcess, RealtimeSessionResponse, SearchMessage, SearchOptions, } from "./types.js";
|
|
8
|
+
export type { ClientOptions, ResponseMeta, ChatRequest, ChatMessage, ChatTool, ContentBlock, ChatUsage, ChatResponse, StreamEvent, StreamDelta, StreamToolUse, SessionChatRequest, SessionChatResponse, SessionToolResult, ContextConfig, ContextMetadata, AgentRequest, AgentWorkerConfig, AgentEvent, MissionRequest, MissionWorkerConfig, MissionEvent, ImageRequest, ImageResponse, GeneratedImage, ImageEditRequest, ImageEditResponse, TTSRequest, TTSResponse, STTRequest, STTResponse, MusicRequest, MusicClip, MusicResponse, SoundEffectRequest, SoundEffectResponse, DialogueRequest, DialogueResponse, DialogueVoice, SpeechToSpeechRequest, SpeechToSpeechResponse, IsolateVoiceRequest, IsolateVoiceResponse, RemixVoiceRequest, RemixVoiceResponse, DubRequest, DubResponse, AlignRequest, AlignResponse, AlignedWord, VoiceDesignRequest, VoiceDesignResponse, VoicePreview, StarfishTTSRequest, StarfishTTSResponse, VideoRequest, VideoResponse, GeneratedVideo, VideoStudioRequest, VideoTranslateRequest, PhotoAvatarRequest, DigitalTwinRequest, AsyncJobResponse, AvatarsResponse, HeyGenAvatar, HeyGenTemplatesResponse, HeyGenTemplate, HeyGenVoicesResponse, HeyGenVoice, EmbedRequest, EmbedResponse, DocumentRequest, DocumentResponse, ChunkDocumentRequest, ChunkDocumentResponse, DocumentChunk, ProcessDocumentRequest, ProcessDocumentResponse, RAGSearchRequest, RAGSearchResponse, RAGResult, RAGCorpus, SurrealRAGSearchRequest, SurrealRAGSearchResponse, SurrealRAGResult, SurrealRAGProvidersResponse, SurrealRAGProviderInfo, ModelInfo, PricingInfo, BalanceResponse, UsageEntry, UsageResponse, UsageQuery, UsageSummaryMonth, UsageSummaryResponse, PricingEntry, AccountPricingResponse, JobCreateRequest, JobCreateResponse, JobStatusResponse, JobListResponse, JobStreamEvent, JobListItem, CreateKeyRequest, CreateKeyResponse, KeyDetails, ListKeysResponse, ComputeTemplate, TemplatesResponse, ProvisionRequest, ProvisionResponse, ComputeInstanceInfo, InstancesResponse, InstanceDetailInfo, InstanceResponse, SSHKeyRequest, DeleteResponse, VoiceInfo, VoicesResponse, CloneVoiceRequest, CloneVoiceResponse, ContactRequest, BatchJobInput, BatchSubmitRequest, BatchSubmitResponse, BatchJsonlResponse, BatchJobInfo, BatchJobsResponse, CreditPack, CreditPacksResponse, CreditPurchaseRequest, CreditPurchaseResponse, CreditBalanceResponse, CreditTier, CreditTiersResponse, DevProgramApplyRequest, DevProgramApplyResponse, AuthUser, AuthResponse, AuthAppleRequest, WebSearchRequest, WebSearchResponse, WebSearchResult, NewsResult, VideoSearchResult, LLMContextRequest, LLMContextResponse, ContentChunk, ContextSource, SearchAnswerRequest, SearchAnswerResponse, SearchAnswerChoice, SearchCitation, StatusResponse, Citation, CollectionsListResponse, CollectionDocumentsResponse, CollectionSearchResponse, CreateCollectionRequest, DeleteCollectionResponse, ModelsResponse, RagCorporaResponse, Infobox, Discussion, TextToSpeechRequest, TextToSpeechResponse, SpeechToTextRequest, SpeechToTextResponse, ContactResponse, ContextChunk, ContextOptions, HeyGenAvatarsResponse, JobAcceptedResponse, JobListEntry, PostProcess, RealtimeSessionResponse, SearchMessage, SearchOptions, ScrapeTarget, ScrapeRequest, ScrapeResponse, ScreenshotURL, ScreenshotRequest, ScreenshotResult, ScreenshotResponse, } from "./types.js";
|
|
9
9
|
export { DEFAULT_BASE_URL, TICKS_PER_USD } from "./types.js";
|
|
10
10
|
import type { ChatMessage } from "./types.js";
|
|
11
11
|
/** Create a user message. */
|
package/dist/types.d.ts
CHANGED
|
@@ -2208,3 +2208,53 @@ export interface SearchOptions {
|
|
|
2208
2208
|
freshness?: string;
|
|
2209
2209
|
safe_search?: string;
|
|
2210
2210
|
}
|
|
2211
|
+
/** A single scrape target. */
|
|
2212
|
+
export interface ScrapeTarget {
|
|
2213
|
+
name: string;
|
|
2214
|
+
url: string;
|
|
2215
|
+
type?: string;
|
|
2216
|
+
selector?: string;
|
|
2217
|
+
content?: string;
|
|
2218
|
+
notebook?: string;
|
|
2219
|
+
recursive?: boolean;
|
|
2220
|
+
max_pages?: number;
|
|
2221
|
+
delay_ms?: number;
|
|
2222
|
+
ingest?: string;
|
|
2223
|
+
}
|
|
2224
|
+
/** Request body for submitting a scrape job. */
|
|
2225
|
+
export interface ScrapeRequest {
|
|
2226
|
+
targets: ScrapeTarget[];
|
|
2227
|
+
}
|
|
2228
|
+
/** Response from submitting a scrape job. */
|
|
2229
|
+
export interface ScrapeResponse {
|
|
2230
|
+
job_id: string;
|
|
2231
|
+
status: string;
|
|
2232
|
+
targets: number;
|
|
2233
|
+
request_id: string;
|
|
2234
|
+
}
|
|
2235
|
+
/** A single URL to screenshot. */
|
|
2236
|
+
export interface ScreenshotURL {
|
|
2237
|
+
url: string;
|
|
2238
|
+
width?: number;
|
|
2239
|
+
height?: number;
|
|
2240
|
+
full_page?: boolean;
|
|
2241
|
+
delay_ms?: number;
|
|
2242
|
+
}
|
|
2243
|
+
/** Request body for taking screenshots. */
|
|
2244
|
+
export interface ScreenshotRequest {
|
|
2245
|
+
urls: ScreenshotURL[];
|
|
2246
|
+
}
|
|
2247
|
+
/** A single screenshot result. */
|
|
2248
|
+
export interface ScreenshotResult {
|
|
2249
|
+
url: string;
|
|
2250
|
+
base64: string;
|
|
2251
|
+
format: string;
|
|
2252
|
+
width: number;
|
|
2253
|
+
height: number;
|
|
2254
|
+
error?: string;
|
|
2255
|
+
}
|
|
2256
|
+
/** Response from the screenshot endpoint. */
|
|
2257
|
+
export interface ScreenshotResponse {
|
|
2258
|
+
screenshots: ScreenshotResult[];
|
|
2259
|
+
count: number;
|
|
2260
|
+
}
|