Skip to navigation

SDK Configuration

AI provider credentials

Every agent runner accepts an optional authConfig object with your AI provider credentials. There are two ways to build it.

From Apex configuration

config.get() reads ~/.pensar/config.json, the same file the TUI and pensar CLI write. For any provider key missing from the file it falls back to an environment variable. buildAuthConfig() converts the result into the authConfig shape agents expect:

import { buildAuthConfig } from "@pensar/apex/core/ai";
import { config } from "@pensar/apex/core/config";
const authConfig = buildAuthConfig(await config.get());

This is the recommended approach. It picks up keys saved through /providers, a Pensar Console login from pensar login, and any of these environment variables:

Environment variableProvider
PENSAR_API_KEYPensar Console (inference through the Pensar gateway)
ANTHROPIC_API_KEYAnthropic
OPENAI_API_KEYOpenAI
GOOGLE_GENERATIVE_AI_API_KEYGoogle
OPENROUTER_API_KEYOpenRouter
CONCENTRATE_API_KEYConcentrate
INFERENCE_API_KEYInference.net
HOONIFY_API_KEYHoonify
BEDROCK_API_KEYAmazon Bedrock

config.get() creates ~/.pensar/config.json with defaults if it doesn’t exist yet. Values in the file take precedence over environment variables.

Explicit credentials

To avoid reading or writing ~/.pensar/config.json (for example, in a container), pass credentials directly:

const authConfig = {
anthropicAPIKey: process.env.ANTHROPIC_API_KEY,
};
anthropicAPIKey
string

Anthropic API key.

openAiAPIKey
string

OpenAI API key.

googleAPIKey
string

Google Generative AI API key.

openRouterAPIKey
string

OpenRouter API key.

pensarAPIKey
string

Pensar Console API key. Routes inference through the Pensar gateway.

bedrock
{ apiKey?: string; accessKeyId?: string; secretAccessKey?: string; sessionToken?: string; region?: string }

Amazon Bedrock credentials.

customProviders
CustomProviders

OpenAI-compatible endpoints. Same shape as customProviders in ~/.pensar/config.json. See custom inference endpoints.

Models

Agents take a model string. It uses the same model IDs as the CLI’s --model flag:

ProviderExample model ID
Anthropicclaude-opus-4-6
OpenAIgpt-5.6-sol
Googlegemini-3.1-pro-preview
OpenRouteranthropic/claude-opus-4.6
Pensar Consolepensar:anthropic.claude-opus-4-6-v1
Amazon Bedrockanthropic.claude-opus-4-6-v1
Custom providercustom:<provider-id>:<model>

The model you choose must belong to a provider whose credentials are in authConfig. For the full list, run /models in the TUI or see Supported AI Providers.

Reasoning

Agents accept a reasoning setting that controls extended thinking for models that support it:

reasoning
'default' | 'enabled' | 'disabled' | 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'Defaults to default

default uses the model’s standard behavior. enabled and disabled toggle thinking on models with a binary switch. The effort levels apply to models that support graded reasoning effort.

Pensar Console authentication

The Console API functions (listIssues, dispatchPentest, listApps, …) don’t take credentials as arguments. They read them from Apex configuration on every call: the session saved by pensar login first (refreshed automatically when it expires), then PENSAR_API_KEY. After pensar login, requests are scoped to the workspace you selected.

Set these environment variables to point the SDK at a different Pensar deployment:

Environment variableDefault
PENSAR_API_URLhttps://api.pensar.dev
PENSAR_CONSOLE_URLhttps://console.pensar.dev
PENSAR_GATEWAY_URLhttps://gateway.pensar.dev