{"_id":"@braingrid/ai-sdk-provider","name":"@braingrid/ai-sdk-provider","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@braingrid/ai-sdk-provider","version":"0.1.0","description":"Vercel AI SDK provider for the BrainGrid AI Gateway — call Anthropic & Gemini with no LLM account or API keys","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"build":"tsup","dev":"tsup --watch","type-check":"tsc --noEmit","test":"vitest run","test:watch":"vitest","clean":"rm -rf dist"},"keywords":["ai","ai-sdk","vercel","provider","anthropic","gemini","braingrid","llm","gateway"],"author":{"name":"BrainGrid AI, Inc."},"license":"Apache-2.0","engines":{"node":">=20.0.0"},"repository":{"type":"git","url":"git+https://github.com/BrainGridAI/ai-kit.git","directory":"packages/ai-sdk-provider"},"homepage":"https://github.com/BrainGridAI/ai-kit/tree/main/packages/ai-sdk-provider#readme","bugs":{"url":"https://github.com/BrainGridAI/ai-kit/issues"},"dependencies":{"@ai-sdk/anthropic":"^3.0.0","jose":"^6.0.0"},"peerDependencies":{"ai":">=6.0.0","zod":"^3.25.76 || ^4.1.8"},"peerDependenciesMeta":{"ai":{"optional":false}},"devDependencies":{"@types/node":"^22.0.0","ai":"^6.0.0","tsup":"^8.0.0","typescript":"^5.6.0","vitest":"^3.2.4","zod":"^3.25.76"},"publishConfig":{"access":"public","provenance":false},"_id":"@braingrid/ai-sdk-provider@0.1.0","gitHead":"bf6d410a6568163fa07aee6531ff599067b62180","_nodeVersion":"22.17.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-tseL4ecoUS1y8oTLzDlsGNNeQWNDoKibuXs2cKWUcYebcW3TJCKGnLffRUCNPkyJEntA7JYdCfkWUH/tTrzUbQ==","shasum":"960f8396d68a15c7b9e6e779a81d983060a6a239","tarball":"https://registry.npmjs.org/@braingrid/ai-sdk-provider/-/ai-sdk-provider-0.1.0.tgz","fileCount":8,"unpackedSize":53605,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEPz2c6eEsYiLQG2ZEf9FxDstDf3xY0ntxjBieZHqTM4AiEAr5bTkJWUw9n/GKk6z48nyitQRTUt1Rc8rFVKbIV9uUI="}]},"_npmUser":{"name":"braingrid_tyler","email":"tyler@braingrid.ai"},"directories":{},"maintainers":[{"name":"acossta","email":"nico@acosta.io"},{"name":"braingrid_tyler","email":"tyler@braingrid.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai-sdk-provider_0.1.0_1779834449735_0.1588263637482885"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-26T22:27:29.594Z","0.1.0":"2026-05-26T22:27:29.881Z","modified":"2026-05-26T22:27:30.116Z"},"maintainers":[{"name":"acossta","email":"nico@acosta.io"},{"name":"braingrid_tyler","email":"tyler@braingrid.ai"}],"description":"Vercel AI SDK provider for the BrainGrid AI Gateway — call Anthropic & Gemini with no LLM account or API keys","homepage":"https://github.com/BrainGridAI/ai-kit/tree/main/packages/ai-sdk-provider#readme","keywords":["ai","ai-sdk","vercel","provider","anthropic","gemini","braingrid","llm","gateway"],"repository":{"type":"git","url":"git+https://github.com/BrainGridAI/ai-kit.git","directory":"packages/ai-sdk-provider"},"author":{"name":"BrainGrid AI, Inc."},"bugs":{"url":"https://github.com/BrainGridAI/ai-kit/issues"},"license":"Apache-2.0","readme":"# @braingrid/ai-sdk-provider\n\nVercel AI SDK provider for the **BrainGrid AI Gateway**. Apps built on BrainGrid call Anthropic & Gemini through the gateway with **no LLM account, no API keys, and no auth code** — the project's signing key is provisioned automatically, and the provider mints short-lived, per-session tokens on the server.\n\nIt's a thin wrapper over [`@ai-sdk/anthropic`](https://www.npmjs.com/package/@ai-sdk/anthropic): the gateway speaks the Anthropic Messages shape and translates other providers (Gemini, etc.) server-side, so a single provider serves every model your plan allows.\n\n## Install\n\n```bash\nnpm i @braingrid/ai-sdk-provider ai\n```\n\n## Usage\n\n```ts\nimport { generateText, streamText } from 'ai';\nimport { braingrid } from '@braingrid/ai-sdk-provider';\n\nconst ai = braingrid(); // reads BRAINGRID_PROJECT_SECRET_KEY from env — no setup\n\n// Claude\nconst { text } = await generateText({\n  model: ai('claude-sonnet-4-6'),\n  prompt: 'Summarize this support ticket: …',\n});\n\n// Gemini — same call, different model string\nconst { textStream } = await streamText({\n  model: ai('gemini-2.5-pro'),\n  prompt: 'Write a release note for v2.3 …',\n});\n```\n\nEverything else — tool calls, structured outputs, multi-modal, streaming — comes from the AI SDK itself. There is no BrainGrid-specific API to learn.\n\n## Attribution\n\nCarry per-end-user attribution into the gateway's usage events (for reporting, never for billing identity):\n\n```ts\nconst ai = braingrid({\n  attribution: { end_user_id: 'cust_8842', metadata: { plan: 'pro' } },\n});\n```\n\n## How it works\n\n`BRAINGRID_PROJECT_SECRET_KEY` is a single `bgpk_…` credential bundling the project's private signing key, its key id, and the gateway URL. `braingrid()` decodes it and, for each request, mints a short-lived JWT (30-minute TTL, cached and re-minted on expiry) signed with that key. The gateway resolves the billing org/project from the key id, checks the model against the project's plan allowlist, proxies to the provider, and bills BrainGrid credits.\n\n**Server-only.** The secret key must never reach the browser — call `braingrid()` from server code (route handlers, server actions), exactly as you would a provider holding an API key.\n\n### Direct (non-AI-SDK) calls\n\nIf you call the gateway HTTP API yourself, mint a session token by hand:\n\n```ts\nimport { mintSession } from '@braingrid/ai-sdk-provider';\n\nconst token = await mintSession({ attribution: { end_user_id: 'cust_8842' } });\n// fetch(`${gatewayUrl}/v1/messages`, { headers: { Authorization: `Bearer ${token}` }, … })\n```\n\n## License\n\nApache-2.0\n","readmeFilename":"README.md","_rev":"1-1f073c0f9182b91774031ec810af628c"}