ConsoleClient API Reference
Complete API reference for the Cognipeer Console SDK client.
If you need the raw HTTP endpoint names behind each resource, see Console API Mapping and the Cognipeer Console API Reference.
Constructor
new ConsoleClient(options)
Creates a new Cognipeer Console SDK client instance.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
options.apiKey | string | Yes | Your Cognipeer Console API key |
options.baseURL | string | No | Console host root (default: https://api.cognipeer.com). Legacy URLs ending in /api/client/v1 are stripped automatically. |
options.timeout | number | No | Request timeout in milliseconds (default: 60000) |
options.maxRetries | number | No | Maximum retry attempts (default: 3) |
options.fetch | typeof fetch | No | Custom fetch implementation |
Returns: ConsoleClient
Example:
const client = new ConsoleClient({
apiKey: 'your-api-key',
baseURL: 'https://your-console.example.com',
timeout: 30000,
maxRetries: 5,
});Properties
client.chat
Chat completions API resource.
Type: ChatResource
See Chat API for details.
client.embeddings
Embeddings API resource.
Type: EmbeddingsResource
See Embeddings API for details.
client.vectors
Vector operations API resource.
Type: VectorsResource
See Vectors API for details.
client.files
File management API resource.
Type: FilesResource
See Files API for details.
client.prompts
Prompt template API resource.
Type: PromptsResource
See Prompts API for details.
client.tracing
Agent tracing API resource.
Type: TracingResource
See Tracing API for details.
client.guardrails
Guardrail evaluation API resource.
Type: GuardrailsResource
See Guardrails API for details.
client.memory
Persistent memory stores API resource.
Type: MemoryResource
See Memory API for details.
client.agents
Agents API resource — list, retrieve, and invoke agents using the Responses API format.
Type: AgentsResource
See Agents API for details.
client.browsers
Browser profile API resource — manage the reusable browser containers that own Browser Use defaults, browser sessions, and per-browser MCP endpoints.
Type: BrowsersResource
See Browser API for details.
client.browserSessions
Browser session API resource — create Playwright-backed sessions, execute discrete browser actions, inspect snapshots, and persist artifacts.
Type: BrowserSessionsResource
See Browser API for details.
client.browserMcp
Browser MCP helper resource — build browser-scoped MCP URLs and discover the Browser Use toolset exposed by a browser profile.
Type: BrowserMcpResource
See Browser API for details.
client.tools
Unified tools API resource — list, retrieve, execute tools and convert them to Agent SDK-compatible objects.
Type: ToolsResource
See Tools API for details.
client.config
Configuration management API resource — manage config groups, items, secrets, and audit logs.
Type: ConfigResource
See Config API for details.
client.audio
OpenAI-compatible STT, audio translation, and TTS.
Type: AudioResource
See Audio API for details.
client.ocr
Document text extraction (PDFs, images).
Type: OcrResource
See OCR API for details.
client.automations
Inspect and trigger built-in scheduled jobs.
Type: AutomationsResource
See Automations API for details.
client.crawler
Scheduled and ad-hoc web crawling.
Type: CrawlerResource
See Crawler API for details.
client.jsSandbox
Run JavaScript inside a managed isolate.
Type: JsSandboxResource
See JS Sandbox API for details.
client.rerankers
Cohere-compatible reranking.
Type: RerankerResource
See Rerankers API for details.
client.mcp
Talk to the built-in Console MCP server (client.mcp.console) or any tenant-configured MCP server (client.mcp.server(serverKey)).
Type: McpResource
See MCP API for details.
Methods
client.getBaseURL()
Get the configured base URL.
Returns: string
Example:
const baseURL = client.getBaseURL();
console.log(baseURL); // "https://api.cognipeer.com"Type Definitions
ConsoleClientOptions
interface ConsoleClientOptions {
apiKey: string;
baseURL?: string;
timeout?: number;
maxRetries?: number;
fetch?: typeof fetch;
}ChatMessage
interface ChatMessage {
role: 'system' | 'user' | 'assistant' | 'tool';
content: string;
name?: string;
tool_calls?: ToolCall[];
tool_call_id?: string;
}ChatCompletionRequest
interface ChatCompletionRequest {
model: string;
messages: ChatMessage[];
temperature?: number;
top_p?: number;
max_tokens?: number;
stream?: boolean;
stop?: string | string[];
presence_penalty?: number;
frequency_penalty?: number;
user?: string;
request_id?: string;
tools?: Tool[];
tool_choice?: 'none' | 'auto' | object;
}ChatCompletionResponse
interface ChatCompletionResponse {
id: string;
object: string;
created: number;
model: string;
choices: ChatChoice[];
usage: Usage;
request_id?: string;
}EmbeddingRequest
interface EmbeddingRequest {
model: string;
input: string | string[];
encoding_format?: 'float' | 'base64';
user?: string;
request_id?: string;
}EmbeddingResponse
interface EmbeddingResponse {
object: string;
data: Embedding[];
model: string;
usage: Usage;
request_id?: string;
}VectorProvider
interface VectorProvider {
_id: string;
key: string;
driver: string;
label: string;
description?: string;
status: 'active' | 'inactive' | 'error';
credentials?: Record<string, unknown>;
settings?: Record<string, unknown>;
metadata?: Record<string, unknown>;
capabilities?: Record<string, unknown>;
createdAt: string;
updatedAt: string;
}VectorIndex
interface VectorIndex {
_id: string;
key: string;
indexId: string;
name: string;
dimension: number;
metric: 'cosine' | 'euclidean' | 'dotproduct';
providerKey: string;
metadata?: Record<string, unknown>;
createdAt: string;
updatedAt: string;
}Browser Resources
The browser surface is split into three SDK resources:
client.browsersfor browser profiles.client.browserSessionsfor direct browser automation.client.browserMcpfor Browser Use-compatible MCP connection helpers.
The old standalone client.browserAgents surface has been removed. If you want a Console-managed agent to browse the web, attach the Browser Use system tool inside Console and invoke that agent through client.agents.
Error Types
CognipeerError
Base error class for all SDK errors.
class CognipeerError extends Error {
constructor(
message: string,
statusCode?: number,
response?: unknown
);
}Properties:
message: string- Error messagestatusCode?: number- HTTP status code (if applicable)response?: unknown- Raw response data
CognipeerAPIError
Error class for API-specific errors.
class CognipeerAPIError extends CognipeerError {
constructor(
message: string,
statusCode: number,
errorType?: string,
response?: unknown
);
}Properties:
- All properties from
CognipeerError errorType?: string- API error type (e.g., 'invalid_request_error')
Example:
import { CognipeerAPIError } from '@cognipeer/console-sdk';
try {
const response = await client.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello!' }],
});
} catch (error) {
if (error instanceof CognipeerAPIError) {
console.error('Status:', error.statusCode);
console.error('Type:', error.errorType);
console.error('Message:', error.message);
}
}Constants
Default Values
const DEFAULT_BASE_URL = 'https://api.cognipeer.com';
const DEFAULT_TIMEOUT = 60000; // 60 seconds
const DEFAULT_MAX_RETRIES = 3;Usage Patterns
Singleton Pattern
let clientInstance: ConsoleClient | null = null;
export function getClient(): ConsoleClient {
if (!clientInstance) {
clientInstance = new ConsoleClient({
apiKey: process.env.COGNIPEER_API_KEY!,
});
}
return clientInstance;
}Factory Pattern
export function createClient(
environment: 'dev' | 'prod'
): ConsoleClient {
return new ConsoleClient({
apiKey: process.env[`${environment.toUpperCase()}_API_KEY`]!,
});
}Request Wrapper
async function safeRequest<T>(
fn: () => Promise<T>
): Promise<T | null> {
try {
return await fn();
} catch (error) {
if (error instanceof CognipeerAPIError) {
console.error('API Error:', error.message);
}
return null;
}
}
const response = await safeRequest(() =>
client.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello!' }],
})
);