Skip to content
WP EngineDocumentation

Getting started

This guide takes you from browsing the model catalog to a working chat completion.

The model catalog is public, so you don’t need an API key to read it. Use it to find the model IDs that you pass as the model field later.

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

Truncated response:

{
"object": "list",
"data": [
{
"id": "google/gemini-3.8-flash",
"object": "model",
"owned_by": "google",
"provider": "google",
"display_name": "Gemini 3.8 Flash",
"context_window": 1048576,
"pricing": {
"input_per_million": "1.5",
"output_per_million": "7.5",
"pricing_version": "2026-10-28T00:00:00Z",
"unit": "ai_credits"
}
}
]
}

Pick a model id from the response. You pass it as the model field when you make a chat completion.

Create a key and copy the secret somewhere safe. The User Portal shows it once.

For this guide, an Account key with Full access is the quickest option. Any key with Chat set to Write also works.

Put the key in an environment variable. The commands below read it from there, so you don’t have to paste the secret:

Terminal window
export AI_API_KEY="wpe_xxx"
Terminal window
curl https://api.ai.wpengine.com/v1/chat/completions \
-H "Authorization: Bearer $AI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-3.8-flash",
"messages": [
{"role": "system", "content": "You are concise."},
{"role": "user", "content": "What is the speed of light in km/s?"}
]
}'

Truncated response:

{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1716240000,
"model": "google/gemini-3.8-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Approximately 299,792 km/s."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 129,
"completion_tokens_details": {
"reasoning_tokens": 120
},
"total_tokens": 144
}
}

On reasoning models, completion_tokens includes the tokens the model spends reasoning before it returns the answer. The completion_tokens_details.reasoning_tokens field reports that part separately. total_tokens is prompt_tokens plus completion_tokens.

Set "stream": true in the request body to receive a stream of Server-Sent Events. Each event is a JSON chunk shaped like chat.completion.chunk. The stream ends with data: [DONE].

For a complete walkthrough, see Stream a chat completion.


Last updated: