
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
@agi-cli/api
Advanced tools
Type-safe API client for AGI CLI server, generated from OpenAPI specification using @hey-api/openapi-ts.
npm install @agi-cli/api axios
# or
bun add @agi-cli/api axios
# or
pnpm add @agi-cli/api axios
import { client, ask, listSessions } from '@agi-cli/api';
// Configure the client once at app startup
client.setConfig({
baseURL: 'http://localhost:3000',
});
// Make type-safe API calls
const response = await ask({
body: {
prompt: 'Hello, AI!',
sessionId: 'optional-session-id',
},
});
if (response.error) {
console.error('Error:', response.error);
} else {
console.log('Response:', response.data);
}
// List all sessions
const sessions = await listSessions();
console.log('Sessions:', sessions.data);
import { client } from '@agi-cli/api';
client.setConfig({
baseURL: 'http://localhost:3000',
// Optional: configure timeout
timeout: 30000,
});
import { client } from '@agi-cli/api';
// Access the underlying Axios instance
client.instance.interceptors.request.use((config) => {
// Add authentication token
config.headers.set('Authorization', `Bearer ${getToken()}`);
return config;
});
client.instance.interceptors.response.use(
(response) => response,
(error) => {
console.error('API Error:', error);
return Promise.reject(error);
}
);
import { client } from '@agi-cli/api';
// Configure auth token (will be added to requests that require auth)
client.setConfig({
baseURL: 'http://localhost:3000',
auth: () => `Bearer ${getToken()}`,
});
All SDK functions are auto-generated and fully typed. Import them directly:
import {
// Session management
listSessions,
createSession,
subscribeSessionStream,
// Messages
listMessages,
createMessage,
// Ask endpoint
ask,
} from '@agi-cli/api';
For endpoints that support Server-Sent Events:
import { createSSEStream } from '@agi-cli/api';
const stream = createSSEStream({
url: 'http://localhost:3000/v1/sessions/session-123/stream',
onMessage: (event) => {
console.log('Event:', event);
},
onError: (error) => {
console.error('Stream error:', error);
},
});
// Close the stream when done
stream.close();
import { ask, isApiError, handleApiError } from '@agi-cli/api';
const response = await ask({
body: { prompt: 'Hello' },
});
if (response.error) {
if (isApiError(response.error)) {
// Handle API errors
const { status, message } = handleApiError(response.error);
console.error(`API Error [${status}]:`, message);
} else {
// Handle network or other errors
console.error('Unexpected error:', response.error);
}
}
The client is auto-generated from the server's OpenAPI specification:
# Generate from the latest server spec
bun run generate
# Build the package
bun run build
The code generation is configured in openapi-ts.config.ts:
import { defineConfig } from '@hey-api/openapi-ts';
export default defineConfig({
input: './openapi.json',
output: {
path: './src/generated',
},
plugins: [
'@hey-api/typescript', // Generate TypeScript types
'@hey-api/schemas', // Generate runtime schemas
'@hey-api/sdk', // Generate SDK functions
'@hey-api/client-axios', // Use Axios client
],
});
@agi-cli/api/
├── src/
│ ├── generated/ # Auto-generated files (don't edit!)
│ │ ├── client.gen.ts # Axios client instance
│ │ ├── sdk.gen.ts # SDK functions
│ │ ├── types.gen.ts # TypeScript types
│ │ └── schemas.gen.ts # Runtime schemas
│ ├── runtime-config.ts # Client runtime configuration
│ ├── streaming.ts # SSE utilities
│ ├── utils.ts # Helper functions
│ └── index.ts # Public API exports
├── openapi-ts.config.ts # Code generation config
├── generate.ts # Generation script
└── build.ts # Build script
If you're migrating from the old Fetch-based client:
import { createApiClient } from '@agi-cli/api';
const client = createApiClient({
baseUrl: 'http://localhost:3000',
});
const response = await client.ask({
prompt: 'Hello',
});
import { client, ask } from '@agi-cli/api';
// Configure once at startup
client.setConfig({
baseURL: 'http://localhost:3000',
});
// Use SDK functions
const response = await ask({
body: { prompt: 'Hello' },
});
MIT
FAQs
Type-safe API client for AGI CLI server
We found that @agi-cli/api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.