Download the PHP package chubes4/ai-http-client without Composer
On this page you can find all versions of the php package chubes4/ai-http-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chubes4/ai-http-client
More information about chubes4/ai-http-client
Files in chubes4/ai-http-client
Package ai-http-client
Short Description A professional WordPress library for unified AI provider communication. Supports OpenAI, Anthropic, Google Gemini, Grok, and OpenRouter with standardized request/response formats.
License GPL-3.0-or-later
Homepage https://github.com/chubes4/ai-http-client
Informations about the package ai-http-client
AI HTTP Client for WordPress
Archived: This package is superseded by WordPress core's
wp-ai-clientAPIs. Data Machine no longer uses this runtime dependency; provider/model/key administration and image generation have moved towp-ai-client-shaped capabilities. This repository remains available for historical reference only and should not be used for new work.
A professional WordPress library for unified AI provider communication. Supports OpenAI, Anthropic, Google Gemini, Grok, and OpenRouter with standardized request/response formats.
Key Features:
- WordPress filter-based architecture with self-contained provider classes
- Unified request/response format across all AI providers
- Comprehensive caching system with 24-hour model cache TTL
- Multi-modal support (text, images, files) via native Files API integration
- Streaming and standard request modes with proper error handling
- REST API endpoints for configuration and management
- Multisite network-wide API key storage support
- Comprehensive error handling with WordPress action hooks
Installation
Composer (recommended for standalone use):
Git Subtree (recommended for plugin embedding):
Manual Installation: Download and include in your WordPress plugin or theme
Requirements: PHP 7.4+, WordPress environment
Upgrading from v1.x to v2.0
Breaking Changes: All filter/action hooks renamed from ai_* to chubes_ai_* for WordPress.org compliance.
Automatic Migration
API keys are automatically migrated on first admin page load:
- Old option:
ai_http_shared_api_keys - New option:
chubes_ai_http_shared_api_keys - Old option deleted after 30 days
Hook Migration
Update all references in your code:
See docs/CHANGELOG.md for complete migration details.
Usage
Include Library:
Basic Request:
Advanced Options:
Providers
Comprehensive AI provider support with dynamic model discovery:
- OpenAI - GPT models, OpenAI Responses API, streaming, function calling, native Files API integration
- Anthropic - Claude models, streaming, function calling, native Files API integration with vision support
- Google Gemini - Gemini models, streaming, function calling, native Files API integration with vision support
- Grok/X.AI - Grok models, streaming support
- OpenRouter - 200+ models via unified API gateway
Architecture
- Filter-Based: WordPress-native provider registration via
chubes_ai_providersfilter - Self-Contained: Each provider handles format conversion internally (standard ↔ provider format)
- Unified Interface: All providers accept standard format, return normalized responses
- WordPress-Native: Uses wpremote* for HTTP, WordPress transients for caching
- Modular Design: Provider files self-register, no central coordination needed
- Error Handling: Comprehensive error hook via
chubes_ai_library_erroraction - Performance: 24-hour model caching with granular cache clearing
Multi-Plugin Support
- Plugin-isolated configurations via filter-based settings
- Centralized API key storage in
chubes_ai_http_shared_api_keysoption - Multisite network-wide API key storage support
- No provider conflicts through self-contained architecture
- Independent AI settings per consuming plugin
Core Components
- Providers: Self-contained classes with unified interface (OpenAI, Anthropic, Gemini, Grok, OpenRouter)
- Request Processing: Complete pipeline via
chubes_ai_requestfilter with error handling - HTTP Layer: Centralized
chubes_ai_httpfilter supporting streaming and standard requests - Caching System: Model caching via
AIHttpCacheclass with WordPress transients - REST API: Configuration and management endpoints via
ai_http_clientnamespace - Error Management: Centralized logging via
AIHttpErrorclass
Core Filters
REST API Endpoints
The library provides REST API endpoints for configuration and management:
Available Endpoints:
- GET/POST
/wp-json/ai-http-client/v1/api-keys/{provider}- Get/set API key for specific provider - GET
/wp-json/ai-http-client/v1/models/{provider}- Get available models for a provider - GET
/wp-json/ai-http-client/v1/providers- List all available providers
Multi-Plugin Configuration
Shared API Keys Storage:
Provider Configuration:
AI Tools System
Tool Registration:
Tool Discovery and Usage:
Distribution
- Packagist: Available via
composer require chubes4/ai-http-client - GitHub: https://github.com/chubes4/ai-http-client
- Version: 2.0.7 - Professional WordPress library with BaseProvider architecture
- License: GNU GPL v3
- Dependencies: None (pure WordPress integration)
- Multi-plugin: Safe for concurrent use by multiple WordPress plugins
Adding Providers
Version 2.0.0 Features
WordPress.org Compliance:
- All filter/action hooks renamed from
ai_*tochubes_ai_*prefix - Automatic migration system for API keys and settings
- Backward compatibility migration for 30-day rollback window
Core Architecture:
- WordPress filter-based provider registration with self-contained classes
- Unified request/response format across all providers
- Comprehensive caching system with 24-hour model cache TTL
- Native Files API integration for multi-modal content (text, images, files)
- Streaming and standard request modes with proper error handling
- REST API endpoints for configuration and management
- Multisite network-wide API key storage support
AI Provider Support:
- OpenAI Responses API integration with native Files API support
- Anthropic Claude models with dynamic model discovery and native Files API
- Google Gemini with native Files API and multi-modal support
- Grok/X.AI integration with streaming support
- OpenRouter gateway access to 200+ models
WordPress Integration:
- Native WordPress HTTP API usage with centralized
chubes_ai_httpfilter - WordPress transients for model caching with granular cache clearing
- WordPress options API for settings with multisite support
- Comprehensive error handling via
chubes_ai_library_erroraction hook
Production Usage
This library is actively used in production WordPress plugins:
- Data Machine - AI-powered content processing pipelines with multi-provider support
- WordSurf - AI content editor with streaming responses and function calling
- AI Bot for bbPress - Forum AI responses with contextual conversation management
Debug
Debug Logging Covers:
- HTTP request/response cycles via
chubes_ai_httpfilter - Provider-specific API interactions
- Model caching operations and cache hits/misses
- Streaming request handling
- Error conditions via
chubes_ai_library_erroraction hook - File upload operations to provider APIs
Contributing
Pull requests welcome for:
- Additional AI provider integrations
- Performance optimizations and caching improvements
- WordPress compatibility enhancements
- Template component additions
- Documentation improvements
License
GNU GPL v3 - Chris Huber