Skip to content
 
 

Repository files navigation

cocapn-sdk — One API Key, Any AI Model

npm version SuperInstance

One API key to access OpenAI, Claude, DeepSeek, Gemini, and more. See exactly what it costs.

What This Gives You

  • One API key — route to any model (DeepSeek, GPT-4o, Claude, Gemini) through a single endpoint
  • Cost tracking — every response includes the exact cost, token counts, and provider used
  • Streaming supportchatStream() delivers tokens as they arrive
  • Model catalog — list available models with pricing per token
  • Usage dashboard — query your spend by day, week, or month

Quick Start

npm install cocapn
const cocapn = require('cocapn');
cocapn.apiKey = process.env.COCAPN_API_KEY; // or pass { apiKey: '...' }

// Chat with any model
const response = await cocapn.chat('Explain transformers in one paragraph', {
  model: 'deepseek-chat',
  system: 'You are a concise teacher.'
});

console.log(response.text);      // "Transformers are..."
console.log(response.cost);      // 0.000042
console.log(response.tokens);    // { in: 15, out: 47 }
console.log(response.provider);  // "deepseek"

Streaming

await cocapn.chatStream('Tell me a story', (chunk) => {
  process.stdout.write(chunk);
}, { model: 'gpt-4o' });

List Models

const models = await cocapn.models();
// [{ id: 'deepseek-chat', provider: 'deepseek', costIn: 0.00000014, costOut: 0.00000028 }, ...]

Usage Stats

const usage = await cocapn.usage('week');

API Reference

new Cocapn(options?)

Option Default Description
apiKey COCAPN_API_KEY env Your Cocapn API key
baseURL https://cocapn.ai API base URL

chat(message, options?) → Promise<Response>

Returns { text, cost, tokens: { in, out }, model, provider }.

chatStream(message, onChunk, options?) → Promise<void>

Streams text chunks to onChunk(delta: string).

models() → Promise<Model[]>

usage(period?) → Promise<Usage>

How It Fits

The unified model gateway for the SuperInstance fleet:

Installation

npm install cocapn

Requires Node.js 18+. MIT license.

About

cocapn SDK — npm install cocapn — one API key, any AI model

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages