curl
These snippets cover the two requests you will make most often against
the Power API — listing models and creating a chat completion — using
nothing more than curl. They are useful for discovering available
models, smoke-testing a new key, debugging a failing client, or
scripting one-off calls from a shell.
Replace wpe_xxx with your Power console-issued API key on authenticated
requests.
List models
Section titled “List models”Use this call to discover the model identifiers you can pass to the chat endpoint. No authentication is required. It is also the cheapest request you can make — no upstream provider is invoked.
curl https://api.ai.wpengine.com/v1/modelsChat completion
Section titled “Chat completion”A non-streaming chat completion returns the full assistant message in a single JSON response. Use this shape when you need the whole answer before doing anything with it.
curl https://api.ai.wpengine.com/v1/chat/completions \ -H "Authorization: Bearer wpe_xxx" \ -H "Content-Type: application/json" \ -d '{ "model": "google/gemini-3.5-flash", "messages": [ {"role": "system", "content": "You are concise."}, {"role": "user", "content": "Summarise the speed of light."} ], "temperature": 0.2 }'Streaming chat completion
Section titled “Streaming chat completion”Streaming returns the response as it is generated, which is the right
choice for interactive UIs. Add "stream": true and process the
response as Server-Sent Events. curl --no-buffer keeps lines from
being buffered locally.
curl --no-buffer https://api.ai.wpengine.com/v1/chat/completions \ -H "Authorization: Bearer wpe_xxx" \ -H "Content-Type: application/json" \ -d '{ "model": "google/gemini-3.5-flash", "stream": true, "messages": [ {"role": "user", "content": "Explain how a CDN works in about 100 words."} ] }'Each event arrives as a data: { ... } line. The stream ends with
data: [DONE].
Failure handling
Section titled “Failure handling”Any of these calls can fail for transport, auth, or rate-limit reasons.
Handle each class differently — retrying a 400, for example, will
never succeed.
- Transport failure — A non-zero curl exit code indicates DNS, TLS, or connection-reset issues. Retry with backoff.
- Rate limited (
429) — Back off with jitter and retry; see rate limits. - Other
4xx— Will not succeed on retry. Inspect the response body and fix the request.