@anek-codes/sdk
v0.1.1
Published
TypeScript SDK for the Anek API
Maintainers
Readme
Anek TypeScript SDK
A TypeScript SDK for the Anek API. It uses HTTP calls and an API key (Bearer token by default).
Install
npm install @anek-codes/sdkQuick start
import { AnekClient } from '@anek-codes/sdk'
import type { Task, TaskLogEntry } from '@anek-codes/sdk'
const client = new AnekClient({
baseUrl: 'http://localhost:3000',
apiKey: 'YOUR_PERSONAL_ACCESS_TOKEN',
})
const task = await client.agents.create({
prompt: 'Add a health check endpoint to the API',
repos: [
{
url: 'https://github.com/acme/my-repo',
baseBranch: 'main',
},
],
selectedAgent: 'claude',
})
const status = await client.agents.status(task.id)
const logs = await client.agents.logs(task.id, { limit: 100 })
const messages = await client.agents.messages(task.id)Available AI Models
Anek supports multiple AI agents and models. You can specify both selectedAgent and selectedModel when creating tasks.
Supported Agents
- claude - Anthropic's Claude models (default:
claude-sonnet-4-5-20250929) - codex - OpenAI GPT models optimized for code (default:
openai/gpt-5.1) - copilot - GitHub Copilot models (default:
claude-sonnet-4.5) - cursor - Cursor AI models (default:
auto) - gemini - Google's Gemini models (default:
gemini-3-pro-preview) - opencode - Open-source and general models (default:
gpt-5)
Example with Different Models
// Use Claude Opus for complex tasks
const task = await client.agents.create({
prompt: 'Refactor the authentication system',
repos: [{ url: 'https://github.com/acme/my-repo', baseBranch: 'main' }],
selectedAgent: 'claude',
selectedModel: 'claude-opus-4-5-20250201',
})
// Use GPT-5.1 Codex for code generation
const codeTask = await client.agents.create({
prompt: 'Generate REST API endpoints',
repos: [{ url: 'https://github.com/acme/my-repo', baseBranch: 'main' }],
selectedAgent: 'codex',
selectedModel: 'openai/gpt-5.1-codex',
})For the complete list of available models, visit the documentation at docs.anek.codes/concepts/models
Sequences (multi-agent)
const sequence = await client.sequences.create({
repos: [
{
url: 'https://github.com/acme/my-repo',
baseBranch: 'main',
},
],
steps: [
{
name: 'analysis',
prompt: 'Analyze the repo and write an analysis.md with changes needed.',
selectedAgent: 'gemini',
},
{
name: 'implement',
prompt: 'Apply the plan from {{previousStep.response}} and update the code.',
selectedAgent: 'claude',
},
],
})
const taskId = sequence.task.idYou can also call client.agents.createSequence as a convenience alias.
For local development in this repo, you can also import from ./sdk/typescript.
Wait for completion
const completed = await client.agents.waitForCompletion(task.id, {
intervalMs: 2000,
})Stream messages and logs (SSE)
Real-time streaming of messages, logs, and task updates:
await client.tasks.streamMessages(task.id, {
onInit: (data) => {
console.log(`Initial: ${data.messages.length} messages, ${data.logs.length} logs`)
},
onMessage: (message) => {
console.log(`[${message.role}] ${message.content}`)
},
onLog: (log) => {
console.log(`[${log.type}] ${log.message}`)
},
onTaskUpdate: (task) => {
console.log(`Status: ${task.status}, Progress: ${task.progress}%`)
},
onComplete: (data) => {
console.log(`Completed with status: ${data.status}`)
},
})See sdk-e2e-test/STREAMING_API.md for detailed documentation.
Stream logs (polling)
for await (const log of client.agents.watchLogs(task.id, { intervalMs: 1500 })) {
handleLogEntry(log)
}Authentication
apiKeyis sent as a Bearer token in theAuthorizationheader by default.- Override
apiKeyHeaderorapiKeyPrefixif your deployment uses a different scheme.
const client = new AnekClient({
baseUrl: 'https://api.example.com',
apiKey: 'YOUR_API_KEY',
apiKeyHeader: 'x-api-key',
apiKeyPrefix: '',
})Build and test
cd sdk/typescript
npm install
npm run build
npm testPublish (npm)
Publishing is automated via GitHub Actions in /.github/workflows/publish-anek-sdk.yml.
- Update the version in
sdk/typescript/package.json. - Create a git tag like
anek-sdk-v0.1.0and push it. - Ensure the repo has the
NPM_TOKENsecret configured.
The workflow builds, tests, and publishes the package from sdk/typescript.
API surface
client.agents: create/status/logs/messages helpers plus polling utilitiesclient.tasks: full task API (files, diffs, PRs, sandbox control, deployments)client.auth: session, PATs, OAuth connect helpersclient.apiKeys: store/check model provider keysclient.git,client.github,client.gitlab,client.bitbucket: repo discovery and metadataclient.repos: commits, issues, pull requestsclient.sandboxes: list, health, lifecycleclient.deployments,client.deploymentTokens: deployment logs and tokensclient.credits,client.payments: billing APIsclient.vercel: scope listingclient.connectors,client.taskManagement: connector managementclient.mcp: JSON-RPC interfaceclient.webhooks: webhook helpersclient.misc: health, OpenAPI, GitHub stars, Sentry test
