Skip to content

OpenAI and Anthropic support

Choose a tag to compare

@psarno psarno released this 22 Oct 01:05
· 13 commits to main since this release

Added

  • OpenAI Provider: Native support for OpenAI API via new OpenAIProvider class

    • Direct integration with OpenAI's chat completion API
    • Support for all OpenAI chat models (GPT-5, GPT-4, GPT-3.5, etc.)
    • Automatic cost tracking using OpenAI's pricing model
    • Dynamic model catalog fetching from OpenAI API
    • Rate limiting protection
    • Configuration via OPENAI_API_KEY environment variable
  • Anthropic Provider: Native support for Anthropic Claude models via new AnthropicProvider class

    • Uses Anthropic's OpenAI-compatible API endpoint
    • Support for all Claude models (Claude 4.5 Sonnet, Claude 4.5 Haiku, etc.)
    • Hardcoded model catalog with pricing information for cost tracking
    • Rate limiting protection
    • Configuration via ANTHROPIC_API_KEY environment variable
  • New Model Packages: Organized model-specific logic into dedicated packages

    • dialectus.engine.models.anthropic: Anthropic model definitions and pricing
    • dialectus.engine.models.openai: OpenAI model definitions and pricing
    • Enhanced model info classes for provider-specific metadata

Changed

  • Extracted common OpenAI SDK logic into base provider class

    • New OpenAICompatibleProviderBase abstract base class centralizes:
      • Chat completion generation (sync and streaming)
      • Metadata extraction (tokens, cost, timing)
      • Rate limiting and backoff logic
      • Error handling and retry mechanisms
    • Eliminates code duplication across OpenAI-compatible providers
    • All providers using OpenAI SDK now extend this base class:
      • OpenRouterProvider refactored to use base class
      • OpenAIProvider implemented using base class
      • AnthropicProvider implemented using base class
      • OllamaProvider updated to align with new architecture
  • Provider Architecture: Improved separation of concerns

    • Providers can override specific methods while inheriting common behavior
    • Cleaner abstraction for provider-specific API differences
    • Better support for future OpenAI-compatible providers
  • Configuration: Extended system configuration for new providers

    • Added openai configuration section in SystemConfig
    • Added anthropic configuration section in SystemConfig
    • Updated example config to demonstrate all provider options
  • Logging: Improved cost reporting

    • Cost messages now logged at INFO level instead of WARNING
    • Better visibility into token usage and costs during debates

Migration Notes

For users upgrading from 0.3.1:

  1. OpenRouter users: No changes required - existing configurations continue to work
  2. New OpenAI support: To use OpenAI directly, set OPENAI_API_KEY and configure provider as "openai"
  3. New Anthropic support: To use Claude models, set ANTHROPIC_API_KEY and configure provider as "anthropic"
  4. Configuration: Update your config files to take advantage of new provider options (see debate_config.example.json)