Chat Completions
OpenAI-compatible chat API with full streaming support. Build conversational AI applications with ease.
Official TypeScript/JavaScript SDK for AI services
npm install @cognipeer/cgate-sdkyarn add @cognipeer/cgate-sdkpnpm add @cognipeer/cgate-sdkimport { CGateClient } from '@cognipeer/cgate-sdk';
const client = new CGateClient({
apiKey: 'your-api-key',
});
// Chat completion
const response = await client.chat.completions.create({
model: 'gpt-4',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello!' },
],
});
console.log(response.choices[0].message.content);
// Streaming
const stream = await client.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Tell me a story' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}📖 Documentation
Check out the Getting Started Guide to learn more.
💡 Examples
Explore our Examples for common use cases and patterns.
🆘 Support
Need help? Open an issue on GitHub.