SDK Overview
The official TypeScript/JavaScript SDK for Cobbl
The Cobbl SDK provides a simple, type-safe way to integrate your applications with the Cobbl platform.
The SDK is fully written in TypeScript with comprehensive type definitions for all APIs.
Best Practice
Always run prompts server-side using the CobblAdminClient and store the
returned runId alongside the AI response in your database. This enables you
to collect user feedback later and link it back to the exact prompt run.
Features
🚀
Simple API
Run prompts and collect feedback with just a few lines of code.
🔒
Type-safe
Full TypeScript support with comprehensive type definitions.
🎯
Framework Agnostic
Works with Node.js, Next.js, Express, and any JavaScript framework.
📦
Zero Config
Works out of the box with sensible defaults.
🌐
Cross-platform
Supports CommonJS, ES modules, and CDN script tags.
⚡
Optimized
Minimal bundle size, tree-shakeable exports.
Two Client Types
The SDK provides two specialized clients for different use cases:
CobblAdminClient
Server-side operations requiring authentication. Use for running prompts and accessing prompt metadata.
CobblPublicClient
Client-facing operations without authentication. Use for collecting and updating user feedback.
Quick Comparison
| Feature | CobblAdminClient | CobblPublicClient |
|---|---|---|
| Use case | Server-side | Client-side |
| Authentication | API key required | None required |
| Running prompts | ✅ | ❌ |
| Submitting feedback | ❌ | ✅ |
| Safe for browsers | ❌ | ✅ |
Quick Example
import { CobblAdminClient } from '@cobbl-ai/sdk'
import { CobblPublicClient } from '@cobbl-ai/sdk'
// Server-side: Run a prompt
const adminClient = new CobblAdminClient({
apiKey: process.env.COBBL_API_KEY,
})
const result = await adminClient.runPrompt('customer_email', {
customerName: 'John Doe',
issue: 'login_problem',
urgency: 'high',
})
console.log(result.output)
// => "Dear John Doe, We understand you're experiencing login issues..."
// Client-side: Collect feedback
const publicClient = new CobblPublicClient()
await publicClient.createFeedback({
runId: result.runId,
helpful: 'helpful',
userFeedback: 'Perfect response!',
})