Overview
Server-side client for running prompts with the Cobbl SDK
The CobblAdminClient is designed for server-side operations that require authentication. Use this client when you need to execute prompts on behalf of your users.
Keep your API key secure! Never expose it in client-side code or commit it to version control.
When to Use CobblAdminClient
- Running prompts with variables
- Accessing prompt metadata and version information
- Server-side applications (Node.js, Next.js API routes, Express)
- Any context where you can securely store your API key
When running prompts, it's best to store the returned runId alongside the AI response in your database. This allows you to link user feedback back to the exact prompt run later.
const result = await adminClient.runPrompt('recommendation', { userId: '123' })
// Store both the output and runId in your database
await db.recommendations.create({
userId: '123',
content: result.output,
cobblRunId: result.runId, // ← Store for feedback collection
})Once you have the runId, you can use it to collect feedback with the CobblPublicClient or Feedback Widget on the client-side.
For submitting user feedback, use the CobblPublicClient instead. It's designed for client-facing operations and doesn't require authentication.
Installation
npm install @cobbl-ai/sdkGetting Your API Key
Navigate to API Keys
Go to Settings → API Keys in the sidebar.
Create a New Key
Click Create API Key and give it a descriptive name.
Copy Your Key
Copy the generated key - you won't be able to see it again!
Keep your API key secure! Never expose it in client-side code or commit it to version control.
Environment Variables
We recommend storing your API key in environment variables:
COBBL_API_KEY=your_api_key_hereInitialization
import { CobblAdminClient } from '@cobbl-ai/sdk'
const adminClient = new CobblAdminClient({
apiKey: process.env.COBBL_API_KEY,
})Configuration Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes | - | Your Cobbl API key |
Methods
runPrompt
Execute a prompt with the given input variables.
const result = await adminClient.runPrompt(promptSlug, input)| Parameter | Type | Description |
|---|---|---|
promptSlug | string | The unique slug identifier for the prompt |
input | PromptInput | Object containing variables to fill the prompt |
See Running Prompts for detailed usage examples.
Import Patterns
Namespaced Import
For optimal tree-shaking and bundle size:
import { CobblAdminClient } from '@cobbl-ai/sdk'This approach results in smaller bundle sizes as unused code is eliminated.