Skip to content
WP EngineDocumentation

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.

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.

Terminal window
curl https://api.ai.wpengine.com/v1/models

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.

Terminal window
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 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.

Terminal window
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].

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.

Last updated: