quantum-ai-sdk 0.3.4 → 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 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, } 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/rag.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { QuantumClient } from "./client.js";
2
- import type { RAGCorpus, RAGSearchRequest, RAGSearchResponse, SurrealRAGProvidersResponse, SurrealRAGSearchRequest, SurrealRAGSearchResponse } from "./types.js";
2
+ import type { RAGCorpus, RAGSearchRequest, RAGSearchResponse, SurrealRAGProvidersResponse, SurrealRAGSearchRequest, SurrealRAGSearchResponse, Collection, CollectionDocument, CollectionSearchRequest, CollectionSearchResult } from "./types.js";
3
3
  /**
4
4
  * Search Vertex AI RAG corpora for relevant documentation.
5
5
  * @internal — called by QuantumClient.ragSearch()
@@ -20,3 +20,9 @@ export declare function surrealRagSearch(client: QuantumClient, req: SurrealRAGS
20
20
  * @internal — called by QuantumClient.surrealRagProviders()
21
21
  */
22
22
  export declare function surrealRagProviders(client: QuantumClient): Promise<SurrealRAGProvidersResponse>;
23
+ export declare function collectionsList(client: QuantumClient): Promise<Collection[]>;
24
+ export declare function collectionsCreate(client: QuantumClient, name: string): Promise<Collection>;
25
+ export declare function collectionsGet(client: QuantumClient, id: string): Promise<Collection>;
26
+ export declare function collectionsDelete(client: QuantumClient, id: string): Promise<void>;
27
+ export declare function collectionsDocuments(client: QuantumClient, collectionId: string): Promise<CollectionDocument[]>;
28
+ export declare function collectionsSearch(client: QuantumClient, req: CollectionSearchRequest): Promise<CollectionSearchResult[]>;
package/dist/rag.js CHANGED
@@ -42,3 +42,27 @@ export async function surrealRagProviders(client) {
42
42
  const { data } = await client._doJSON("GET", "/qai/v1/rag/surreal/providers", undefined);
43
43
  return data;
44
44
  }
45
+ // ── RAG Collections (user-scoped xAI proxy) ─────────────────────
46
+ export async function collectionsList(client) {
47
+ const { data } = await client._doJSON("GET", "/qai/v1/rag/collections", undefined);
48
+ return data.collections;
49
+ }
50
+ export async function collectionsCreate(client, name) {
51
+ const { data } = await client._doJSON("POST", "/qai/v1/rag/collections", { name });
52
+ return data;
53
+ }
54
+ export async function collectionsGet(client, id) {
55
+ const { data } = await client._doJSON("GET", `/qai/v1/rag/collections/${id}`, undefined);
56
+ return data;
57
+ }
58
+ export async function collectionsDelete(client, id) {
59
+ await client._doJSON("DELETE", `/qai/v1/rag/collections/${id}`, undefined);
60
+ }
61
+ export async function collectionsDocuments(client, collectionId) {
62
+ const { data } = await client._doJSON("GET", `/qai/v1/rag/collections/${collectionId}/documents`, undefined);
63
+ return data.documents;
64
+ }
65
+ export async function collectionsSearch(client, req) {
66
+ const { data } = await client._doJSON("POST", "/qai/v1/rag/collections/search", req);
67
+ return data.results;
68
+ }