Chatelope
Plugins

Provider Plugins

Add custom AI providers

Provider Plugins

Provider plugins add new AI services to Chatelope, enabling chat with custom APIs, enterprise deployments, or specialized models.

How Providers Work

  1. Plugin registers as an AI provider
  2. User configures the provider (API key, URL, etc.)
  3. Chatelope sends messages through the plugin
  4. Plugin handles API communication
  5. Responses display in the chat

Available Providers

Built-in Providers

  • OpenAI (GPT models)
  • Anthropic (Claude models)
  • Google (Gemini models)
  • Ollama (local models)
  • LM Studio (local models)

Community Providers

ProviderDescriptionStatus
azure-openaiAzure OpenAI ServiceVerified
aws-bedrockAWS BedrockVerified
groqGroq CloudCommunity
together-aiTogether AICommunity

Using Provider Plugins

After Installation

New providers appear in AI settings:

  1. Go to Settings > AI Settings
  2. New provider appears in dropdown
  3. Configure credentials
  4. Select models

Configuration

Each provider has its own settings:

  • API keys
  • Endpoint URLs
  • Model selection
  • Request parameters

Creating Provider Plugins

See Creating Plugins for the full SDK guide.

Quick Example

import { defineProvider, Message } from '@chatelope/plugin-sdk';

export default defineProvider({
  id: 'my-provider',
  name: 'My AI Provider',
  version: '1.0.0',

  // Configuration schema
  config: {
    apiKey: {
      type: 'string',
      label: 'API Key',
      secret: true,
      required: true,
    },
    baseUrl: {
      type: 'string',
      label: 'API URL',
      default: 'https://api.example.com',
    },
  },

  // List available models
  getModels: async (config) => {
    const response = await fetch(`${config.baseUrl}/models`, {
      headers: { Authorization: `Bearer ${config.apiKey}` },
    });
    return response.json();
  },

  // Send messages and stream response
  chat: async function* (messages: Message[], config, options) {
    const response = await fetch(`${config.baseUrl}/chat`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${config.apiKey}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        model: options.model,
        messages,
        stream: true,
      }),
    });

    // Stream the response
    for await (const chunk of streamResponse(response)) {
      yield { content: chunk };
    }
  },
});

Provider Interface

interface Provider {
  id: string;
  name: string;
  version: string;
  icon?: string;

  // Configuration
  config: ConfigSchema;

  // Methods
  getModels(config: Config): Promise<Model[]>;
  chat(messages: Message[], config: Config, options: ChatOptions): AsyncGenerator<ChatChunk>;

  // Optional
  validateConfig?(config: Config): Promise<ValidationResult>;
  getUsage?(config: Config): Promise<UsageInfo>;
}

Message Types

interface Message {
  role: 'user' | 'assistant' | 'system';
  content: string;
  attachments?: Attachment[];
}

interface ChatOptions {
  model: string;
  temperature?: number;
  maxTokens?: number;
  systemPrompt?: string;
}

interface ChatChunk {
  content?: string;
  done?: boolean;
  usage?: TokenUsage;
}

Streaming Responses

Providers should stream responses for better UX:

chat: async function* (messages, config, options) {
  const stream = await createStream(messages);

  for await (const chunk of stream) {
    yield { content: chunk.text };
  }

  yield { done: true, usage: stream.usage };
}

Error Handling

Handle API errors gracefully:

chat: async function* (messages, config, options) {
  try {
    // API call
  } catch (error) {
    if (error.status === 401) {
      throw new ProviderError('Invalid API key', 'auth_error');
    }
    if (error.status === 429) {
      throw new ProviderError('Rate limited', 'rate_limit');
    }
    throw new ProviderError('API error', 'api_error');
  }
}

Best Practices

  1. Stream responses - Better user experience
  2. Handle rate limits - Implement backoff
  3. Validate configs - Check credentials early
  4. Report usage - Track token consumption
  5. Support cancellation - Handle AbortController
  6. Document requirements - API key instructions

On this page