Quickstart
Install the Coresource SDK, set your API key, and run your first agent. Pick your setup: SDK, Claude Code, or Codex.
1Install and authenticate
The SDK is ESM-only, so use import, not require. Every entry point reads CORESOURCE_API_KEY from the environment.
npm install @coresourceai/sdk
export CORESOURCE_API_KEY='your-api-key'To pass the key explicitly, point at another deployment, or supply your own fetch, see Authentication.
2Define an agent
createAgent is synchronous and lazy — it does no network work until run() or start(). Nothing is validated against the server at construction time.
import { createAgent } from '@coresourceai/sdk';
const agent = createAgent({
type: 'saga',
model: 'deepseek/deepseek-v4-flash',
effort: 'xhigh',
systemPrompt: `You reconcile invoices against the ledger.
Follow the field rules exactly, and never invent a value
a source system did not state.`,
outputs: ['report.md']
});
const result = await agent.run('Reconcile last quarter and flag exceptions.');
console.log(result.text);The model line names where the router starts; it escalates to premium models when your plan allows. Learn how to choose an agent type in Agent types.
3Watch it run
run() waits for the final result, which is right for a script and wrong when a person is watching. start() returns as soon as the run exists and events() streams what it is doing.
const codingAgent = createAgent({ type: 'agent' });
// file_read, file_write, file_edit, glob, grep, web_fetch, execute
codingAgent.registerRuntimeTools();Continue with Running agents (files, artifacts, cancellation) or Tools to give an agent your database or browser.
1Create a key and point Claude Code at the gateway
No plugin, no wrapper, no new tools. Claude Code talks to the Coresource gateway the same way it talks to Anthropic — the only change is two lines of configuration. Create an API key in the console, then add this to your ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.coresource.ai",
"ANTHROPIC_AUTH_TOKEN": "your-coresource-api-key",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "makora/deepseek-v4-flash",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "makora/kimi-k3",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "makora/deepseek-v4-flash"
}
}ANTHROPIC_BASE_URL is where Claude Code sends every request, and ANTHROPIC_AUTH_TOKEN is your Coresource key, sent as a bearer token. From there the auto-router handles model selection on every request within whatever your plan allows — there is no model list to configure.
2Restart Claude Code and confirm the endpoint
claude
# inside the session, confirm requests go through the gateway
/statusPrefer to scope it to one project? The same env block works in .claude/settings.local.json at the repository root, which stays out of version control. Contact us for the full setup with both terminals.
1Create a key and configure the provider
Codex speaks the OpenAI wire format, which the gateway serves on the same key and plan balance as Claude Code. One provider block points it at the auto-router. Create an API key in the console, then add this to your ~/.codex/config.toml:
model = "makora/deepseek-v4-flash"
model_provider = "coresource"
[model_providers.coresource]
name = "Coresource"
base_url = "https://api.coresource.ai/v1"
env_key = "CORESOURCE_API_KEY"
wire_api = "responses"model_provider selects the Coresource provider, base_url points at the gateway, and env_key is the environment variable Codex reads your key from. The model line names where the router starts. OpenAPI-compatible requests land on the same balance as Claude Code.
2Export your key and confirm the provider
Codex reads CORESOURCE_API_KEY from the environment at launch — it does not read a .env file itself. Put the export in your shell profile so it is set every time.
export CORESOURCE_API_KEY='your-coresource-api-key'codex
# inside the session, confirm requests go through the gateway
/model