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.
AI Photo Styles can also use your own provider, but only through filters β there are no wp-config constants for them. See Route AI Photo Styles.
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 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.
Settings that custom mode ignores
The text-to-image settings in Chamevo β Settings β General β AI Services only apply to the hosted service. In custom mode, Chamevo does not send:
the model and resolution from Image Generation Model & Resolution
the image count from Images per Generation
Your provider decides these instead. Set the model with CHAMEVO_AI_TEXT2IMAGE_MODEL, and set size and image count in chamevo_ai_text2image_request_body (for example n and size). Return an array of URLs in output to give customers several images.
The same applies to AI Photo Styles: the Image model chosen per style is not sent to a custom provider. Credits shown in those settings are not charged in custom mode.
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:
The same pre, request_body, request_headers, and response filters apply, with image_filter as {tool}.
Default request body:
{ "image": "https://β¦ or data:image/jpeg;base64,β¦", "prompt": "<the style's prompt>" }
$context carries image, prompt, and the resolved config. The image is a public URL, or an inline JPEG data URI (longest edge 2048 px) when your site is not reachable from the internet. The prompt comes from the style on your server β the customer's browser never sees it.
Return Chamevo's response shape with one result image in output (a URL or a data:image/β¦;base64,β¦ URI). Chamevo saves the result on your server and places it on the canvas.
Styles still need AI Photo Styles enabled in Settings β General β AI Services and a prompt. The Try button on the AI Photo Styles screen uses the same route.
Check your setup
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.
My model or image count settings have no effect β in custom mode, the Image Generation Model & Resolution and Images per Generation settings are not sent. Set them in chamevo_ai_text2image_request_body instead.
AI Photo Styles still spend Chamevo credits β CHAMEVO_AI_IMAGE_FILTER_* constants do not exist. Use the chamevo_ai_image_filter_config filter.
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: Can AI Photo Styles use my own provider?
A: Yes, through filters only. Return an endpoint from chamevo_ai_image_filter_config and map the { image, prompt } body with chamevo_ai_image_filter_request_body if needed.
Q: Does my Images per Generation setting apply to my own provider?
A: No. Model, resolution, and image count from the AI Services settings only apply to the hosted service. Your provider decides them, for example through the request body filter.
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.