tokyo-ai
v0.0.5
Published
Tokyo SDK Tracking Without Code Changes
Readme
🚀 Tokyo — AI Tracking SDK
Status: ✅ Production-Ready
Register : app.usetokyo.com/register
Tokyo SDK is a TypeScript-first client that enables seamless integration with multiple AI providers (OpenAI, Google Gemini, Anthropic Claude) using APIs that mirror their official SDKs — with automatic usage tracking and multi-tenant support.
✅ Supported Providers
| Provider | Status | Main Method | Example |
|----------|--------|-------------|---------|
| OpenAI | ✅ Production-Ready | client.responses.create() | client.responses.create({ model: "gpt-4o", messages: [...] }) |
| Google Gemini | ✅ Production-Ready | client.models.generateContent() | client.models.generateContent({ model: "gemini-2.0-flash", contents: "..." }) |
| Anthropic Claude | ✅ Production-Ready | client.messages.create() | client.messages.create({ model: "claude-3-sonnet", messages: [...] }) |
🎯 Key Features
- 🔌 Native API compatibility – identical syntax to official provider SDKs
- 🔑 Unified authentication – one Tokyo key for all providers
- 💰 Automatic billing – built-in cost tracking per customer
- ⚡ TypeScript-first – full type safety and autocompletion
- 🔄 Cross-provider fallback – retry on alternate providers automatically
- 📊 Complete usage metrics – tokens, costs, request IDs, and more
📦 Installation
npm install tokyo-ai🔧 Quick Setup
import { Tokyo, AI_PROVIDERS } from "tokyo-ai";
const client = new Tokyo(
AI_PROVIDERS.openai, // or gemini, anthropic
"sk_tokyo_your_key",
{ externalCustomerId: "your-customer-id" }
);🌟 Why Choose Tokyo SDK?
🚀 Zero Code Changes
Drop-in replacement for native SDKs. Just update your import:
// Before (Native OpenAI)
import OpenAI from "openai";
const openai = new OpenAI({ apiKey: "sk-..." });
// After (Tokyo SDK)
import { Tokyo, AI_PROVIDERS } from "tokyo-ai";
const openai = new Tokyo(AI_PROVIDERS.openai, "sk_tokyo_...", { externalCustomerId: "123" });
// ✅ Same API, no logic changes📊 Built-In Usage Tracking
- Automatic token and cost tracking
- Real-time metrics in the Tokyo dashboard
- Per-customer billing out of the box
🔑 Unified Key Management
- One Tokyo key for OpenAI, Gemini, Claude, and more
- Keep provider API keys hidden and secure
- Fine-grained permissions and limits
💡 Usage Examples
OpenAI API
const openai = new Tokyo(AI_PROVIDERS.openai, key, config);
const res = await openai.responses.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Tell me a joke." }]
});
console.log(res.choices[0].message.content);
console.log("Cost:", res.usage.cost);Google Gemini
const gemini = new Tokyo(AI_PROVIDERS.gemini, key, config);
const res = await gemini.models.generateContent({
model: "gemini-2.0-flash",
contents: "Explain AI in one sentence."
});
console.log(res.candidates[0].content.parts[0].text);Anthropic Claude
const claude = new Tokyo(AI_PROVIDERS.anthropic, key, config);
const res = await claude.messages.create({
model: "claude-3-sonnet",
messages: [{ role: "user", content: "What is quantum computing?" }]
});
console.log(res.content[0].text);OpenAI Embeddings
const res = await openai.embeddings.create({
model: "text-embedding-3-small",
input: "Hello, world!"
});
console.log("Embedding length:", res.data[0].embedding.length);🔄 Provider Switching
client.updateProvider(AI_PROVIDERS.gemini); // Switch dynamicallyOr create multiple clients:
const openai = new Tokyo(AI_PROVIDERS.openai, key, config);
const gemini = new Tokyo(AI_PROVIDERS.gemini, key, config);🛠 Advanced Configuration
const config = {
externalCustomerId: "your-customer-id", // Required
timeout: 30_000,
retries: 3,
debug: true,
headers: { "X-Custom-Header": "value" }
};🚀 Getting Started
- Register at usetokyo.com
- Create a project and configure providers
- Generate a Tokyo SDK key (
sk_tokyo_...) - Install and import
tokyo-ai - Use APIs with zero code changes
🚧 Limitations
- Streaming: not yet supported (in development)
- File uploads: partial support
🔮 Roadmap
- ✅ OpenAI full API (incl. embeddings & images)
- ✅ Gemini API
- ✅ Anthropic API
- ✅ Automatic billing & multi-tenancy
- 🔄 Streaming responses (coming soon)
- 🔄 Response caching
- 🔄 Advanced analytics
📞 Support
- 🌐 Website: usetokyo.com
- 📧 Email: [email protected]
📄 License
MIT License — see LICENSE.
