Preparing your workspace...

assistant-chat.tsx2.5k
utils.ts850
button.tsx720
Quick Actions
codmir
Docs
Discord
Get started
API
  • Introduction
  • Installation
  • Your First Project
  • Your First Agent

Simple client for integrating with the codmir AI chat API.

Chat Client

The Chat Client is a lightweight wrapper for the codmir AI chat API. It's built into the main application and can be used for custom integrations.

Usage

import { codmir, CodmirClient } from '@/lib/codmir-sdk';

// Using the default instance
const response = await codmir.sendMessage('How do I fix this TypeScript error?');
console.log(response);

// Or create your own instance
const client = new CodmirClient();
const response = await client.sendMessage('Explain this code');

API Reference

CodmirClient

class CodmirClient {
  /**
   * Send a message to the AI chat API.
   * @param message - The user's message
   * @returns The AI response as a string
   */
  async sendMessage(message: string): Promise<string>;
}

Integration Examples

React Component

'use client';

import { useState } from 'react';
import { codmir } from '@/lib/codmir-sdk';

export function ChatWidget() {
  const [message, setMessage] = useState('');
  const [response, setResponse] = useState('');
  const [loading, setLoading] = useState(false);

  const handleSubmit = async () => {
    setLoading(true);
    try {
      const result = await codmir.sendMessage(message);
      setResponse(result);
    } finally {
      setLoading(false);
    }
  };

  return (
    <div>
      <input
        value={message}
        onChange={(e) => setMessage(e.target.value)}
        placeholder="Ask codmir..."
      />
      <button onClick={handleSubmit} disabled={loading}>
        {loading ? 'Thinking...' : 'Send'}
      </button>
      {response && <div>{response}</div>}
    </div>
  );
}

Server Action

'use server';

import { codmir } from '@/lib/codmir-sdk';

export async function askCodmir(message: string) {
  return await codmir.sendMessage(message);
}

Advanced: Streaming

For streaming responses, use the Vercel AI SDK directly:

import { useChat } from 'ai/react';

export function StreamingChat() {
  const { messages, input, handleInputChange, handleSubmit } = useChat({
    api: '/api/chat',
  });

  return (
    <form onSubmit={handleSubmit}>
      {messages.map((m) => (
        <div key={m.id}>
          <strong>{m.role}:</strong> {m.content}
        </div>
      ))}
      <input value={input} onChange={handleInputChange} />
    </form>
  );
}

Chat API Endpoint

The client calls POST /api/chat with this format:

// Request
{
  messages: [
    { role: 'user', content: 'Your message' }
  ]
}

// Response (streaming text)
"AI response content..."

Authentication

The Chat API uses session-based authentication. Ensure the user is logged in before making requests.

// Check if authenticated
const session = await getSession();
if (!session) {
  redirect('/login');
}

// Then use the client
const response = await codmir.sendMessage(message);

Rate Limiting

The chat API is rate-limited to prevent abuse:

  • 30 requests per minute per user
  • Returns 429 Too Many Requests when exceeded
try {
  await codmir.sendMessage(message);
} catch (error) {
  if (error.message.includes('Rate limit')) {
    console.log('Please wait before sending more messages');
  }
}

Related

  • AI Fabrick - Advanced AI pipeline configuration
  • Codec SDK - Intent capture and prompt generation
Open in ChatGPTOpen in ClaudeConnect MCP on CursorConnect MCP on WindsurfEdit on GitHub
codmir
Products
Desktop AppMobile AppIDE ExtensionAI AgentsOverseerVoice ModeCortex ProtocolHive MindGame Dev (Godat)PricingDownload
Solutions
AI Code AgentsCode ReviewError TrackingSelf-HealingDeploy TrackingAI Tracking SDKWorkflow AutomationTesting FrameworkTime TrackingVoice Control
Platform
ProjectsTickets & BoardsAgent MarketplaceIntegrationsTemplatesApp HubAdmin PanelAnalytics
Integrations
GitHubSlackDiscordVercelSentryRailwayLinearAll Integrations
Developers
DocumentationAPI ReferenceSDKCLIDeveloper PortalMarketplaceMCP ConnectorsWebhooksExamplesnpm Packages
Resources
BlogChangelogCommunityTutorialsGet StartedSupportStatusFeedback
Company
AboutCareersContact SalesKickstarterReferral Program
Legal
Terms of UsePrivacy PolicyEULATrademarkSecurity
Download on the App StoreGet it on Google Play

Codmir™ 2026. All rights reserved.

Free & open source SDK — Apache 2.0 License