Preparing the latest guides, releases, and feature request updates.
Loading guides
Preparing the right Knowledge Base content for this platform.
Use a custom AI provider | Chamevo Support Center
Use a custom AI provider
Route Chamevo's AI Tools to your own provider endpoint and API key with per-tool wp-config constants or filters, bypassing the hosted Chamevo service and credit usage.
Updated June 3, 20265 min read
By default, Chamevo's AI Tools run through the hosted Chamevo service and spend AI credits. You can point each tool at your own AI provider instead. When you do, Chamevo calls your endpoint directly β it skips the hosted service, sends no Chamevo license header, and spends no Chamevo credits for that tool.
You can route each tool independently. For example, send text-to-image to your own provider while leaving upscaling and background removal on the hosted service.
Before you start
You can edit wp-config.php on your server, or add PHP filters in a plugin or theme.
You have an endpoint URL and API key for each AI tool you want to route.
You know your provider's request and response format. If it differs from Chamevo's default, you will map it with the request and response filters below.
The three AI tools map to these canonical keys:
AI tool
Tool key
Constant infix
Generate images from text
text2image
TEXT2IMAGE
Upscale images
upscale
UPSCALE
Remove backgrounds
remove_background
REMOVE_BACKGROUND
Route a tool with wp-config constants
The simplest setup uses constants in wp-config.php.
Open wp-config.php in the root of your WordPress install.
Above the line that reads /* That's all, stop editing! */, define the endpoint and key for the tool you want to route.
Save the file.
// Route text-to-image to your own provider.
define('CHAMEVO_AI_TEXT2IMAGE_ENDPOINT', 'https://api.example.com/v1/images');
define('CHAMEVO_AI_TEXT2IMAGE_KEY', 'sk-your-provider-key');
define('CHAMEVO_AI_TEXT2IMAGE_MODEL', 'my-image-model'); // optional
As soon as the endpoint constant has a value, that tool is in custom mode. The next time a customer uses it, Chamevo sends the request straight to your endpoint.
Constants reference
Replace {TOOL} with TEXT2IMAGE, UPSCALE, or REMOVE_BACKGROUND.
Constant
Required
Purpose
CHAMEVO_AI_{TOOL}_ENDPOINT
Yes
Full provider URL. A non-empty value enables custom mode.
CHAMEVO_AI_{TOOL}_KEY
Recommended
API key. Sent as Authorization: Bearer β¦.
CHAMEVO_AI_{TOOL}_MODEL
No
Model identifier, added to the request body as model.
What custom mode changes
In custom mode, Chamevo:
Sends the request directly to your endpoint, not to the hosted Chamevo service.
Uses POST with Authorization: Bearer {your key}.
Does not send the Chamevo license header (X_API_TOKEN).
Spends no Chamevo AI credits for that tool.
By default Chamevo sends its own request body and expects its own response shape.
Default request body per tool (plus model when the _MODEL constant is set):
output may be a single URL, an array of URLs, or a data:image/β¦;base64,β¦ URI.
If your provider already accepts this body and returns this shape, the constants alone are enough. If not, map the shapes with the filters below.
Map a provider with a different schema
Most providers use their own request and response formats. Use the request and response filters to translate. {tool} is text2image, upscale, or remove_background.
This example adapts text-to-image to an OpenAI-style image endpoint:
// Reshape the request body to the provider's schema.
add_filter('chamevo_ai_text2image_request_body', function($body, $context) {
return [
'model' => $context['config']['model'] ?: 'gpt-image-1',
'prompt' => $context['prompt'],
'n' => 1,
'size' => '1024x1024',
];
}, 10, 2);
// Normalize the provider response back into Chamevo's shape.
add_filter('chamevo_ai_text2image_response', function($normalized, $raw, $config) {
return [
'status' => 'success',
'data' => ['output' => $raw['data'][0]['url']],
];
}, 10, 3);
$context carries the tool inputs β prompt for text2image, and image_url (plus scale for upscale) for the image tools β along with the resolved config.
Set config at runtime instead of in wp-config
If you cannot edit wp-config.php, or you need to choose the provider dynamically, use the config filter instead of constants:
For providers that create a job and require polling (or that need an SDK), short-circuit the built-in HTTP call with the pre filter. Return Chamevo's response shape and the built-in request is skipped entirely:
Open a product in the customizer and run the AI tool you routed.
Confirm the result image comes back and is added to the canvas.
Check that your Chamevo AI credit balance does not change for that tool β credits are only spent in hosted mode.
If a request fails, enable debug logging and look for a Custom AI provider request failed entry with the tool and endpoint.
Troubleshooting
The tool still uses hosted Chamevo and spends credits β the endpoint constant is empty or misnamed. The name must be exactly CHAMEVO_AI_{TOOL}_ENDPOINT with the tool in uppercase (TEXT2IMAGE, UPSCALE, REMOVE_BACKGROUND), and it must be defined before WordPress loads the plugin.
The provider returns 401 or 403 β the key is missing or wrong. Check the _KEY constant, or set a custom auth header with chamevo_ai_{tool}_request_headers.
The provider rejects the request body β its schema differs from Chamevo's default. Map the body with chamevo_ai_{tool}_request_body.
The image never appears even though the provider responds β the response shape does not match. Map it to { "status": "success", "data": { "output": "<url>" } } with chamevo_ai_{tool}_response.
Only one tool routes correctly β each tool is configured separately. Define constants (or filters) for every tool you want to route.
Q: Does using a custom AI provider stop Chamevo from charging credits?
A: Yes. When a tool is in custom mode, Chamevo calls your endpoint directly and spends no Chamevo AI credits for that tool.
Q: Can I route only one AI tool and leave the others hosted?
A: Yes. Each tool is configured independently. Define constants or filters only for the tools you want to redirect; the rest keep using the hosted Chamevo service.
Q: My provider uses a different request format. Will it still work?
A: Yes, with a small mapping. Use the chamevo_ai_{tool}_request_body and chamevo_ai_{tool}_response filters to translate between your provider's format and Chamevo's expected shape.
Q: Do I have to edit wp-config.php?
A: No. The constants are the simplest route, but you can set the same configuration at runtime with the chamevo_ai_{tool}_config filter in a plugin or theme.