awe docs

For developers

OpenAI-compatible API

The console serves a local API in the OpenAI chat format. Point any tool that can talk to OpenAI (an editor, a script, an SDK) at it, and the answers come from awe: your chosen model, with your memory, skills and connected tools. This page is for developers.

Where it is

Base URL http://127.0.0.1:8765/v1
POST /v1/chat/completions Chat, streaming or not
GET /v1/models The model list

The console listens on 127.0.0.1 only, so the API is reachable from this computer and nowhere else. If port 8765 was taken when awe was installed, the installer chose the next free port and wrote it to .env as WEB_PORT. Use that port in the examples below.

Try it

curl -s http://127.0.0.1:8765/v1/models

curl -s http://127.0.0.1:8765/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "awe-default",
    "messages": [{"role": "user", "content": "What is on my calendar today?"}]
  }'

curl -s http://127.0.0.1:8765/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "awe-default",
    "stream": true,
    "messages": [{"role": "user", "content": "Summarise my open tasks"}]
  }'

The model name

There is one model: awe-default. It means “whatever model the console is set to use”. Change the model in the console under Settings → LLM/Model, not in the request. GET /v1/models returns awe-default, with the active model’s label in metadata.active_model.

The older name oi-default is still accepted and treated as awe-default. Any other model name is accepted too, and echoed back in the response, but it does not change which model answers.

Request

{
  "model": "awe-default",
  "messages": [
    {"role": "user", "content": "your message"}
  ],
  "stream": false,
  "conversation_id": "optional-stable-id"
}
Field Required Notes
messages Yes OpenAI message format. Must contain at least one user message
model No Defaults to awe-default
stream No true for server-sent events. Default is one JSON response
conversation_id No A stable id to keep a conversation going across requests
user No Used as the app name if the X-awe-App header is not sent

How it differs from OpenAI:

  • Only the last user message is used. awe keeps the conversation history itself. Earlier messages in the array are not replayed.
  • system messages are ignored. awe builds its own system prompt.
  • tools, tool_choice, temperature, max_tokens and similar fields are ignored. awe uses its own tools and settings. Tool activity is not shown in the response: you get the final text.
  • Text only. If a message’s content is a list of parts, the text parts are joined and other parts are dropped.
  • The whole message goes to the model, but only its first 10,000 characters are saved in the conversation history.

Keeping a conversation

Send the same conversation_id on each request, in the body or as the X-awe-Conversation-Id header. awe loads that conversation’s history from its own store.

Without an id, every request starts a new conversation.

Response

Not streaming:

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1712345678,
  "model": "awe-default",
  "choices": [{
    "index": 0,
    "message": {"role": "assistant", "content": "..."},
    "finish_reason": "stop"
  }],
  "usage": {"prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0}
}

Streaming sends data: lines. Each chunk has object: "chat.completion.chunk" and a delta.content piece. The last chunk has an empty delta, finish_reason: "stop" and, when the model reported it, usage. The stream ends with:

data: [DONE]

usage holds the token counts the model reported. They are 0 when the model did not report any.

Errors

{"error": {"message": "what went wrong", "type": "server_error"}}
Status type When
400 invalid_request_error messages is missing or empty, or has no user message
401 auth_error A token is required and the header is missing or wrong
403 The request came from another website in a browser, or used a host name other than localhost or 127.0.0.1
500 server_error The chat failed (model unavailable, for example)
503 server_error No model is set up yet. Choose one in Settings → LLM/Model

In a stream that has already started, an error arrives as a data: line with an error object, followed by [DONE].

Require a token

By default no token is needed, because only programs on this computer can reach the port. To require one, add this to .env in your awe folder and restart awe:

AWE_OPENAI_COMPAT_TOKEN=choose-a-long-random-string

Every /v1 request must then send:

Authorization: Bearer choose-a-long-random-string

In an editor or SDK, put the same string in the API key field. Without a token set, clients that insist on an API key can send any value.

Use it from an editor or SDK

Any client that lets you set an OpenAI base URL works. Use base URL http://127.0.0.1:8765/v1, model awe-default, and any API key (or your token).

Python:

from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:8765/v1", api_key="local")
reply = client.chat.completions.create(
    model="awe-default",
    messages=[{"role": "user", "content": "What did I decide about the launch date?"}],
    extra_body={"conversation_id": "launch-notes"},
)
print(reply.choices[0].message.content)

Node.js:

import OpenAI from 'openai';

const client = new OpenAI({ baseURL: 'http://127.0.0.1:8765/v1', apiKey: 'local' });
const stream = await client.chat.completions.create({
  model: 'awe-default',
  stream: true,
  messages: [{ role: 'user', content: 'Summarise my open tasks' }],
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? '');

Because awe ignores client-side tools and replays only the last message, an editor’s own agent features (file edits, tool calls driven by the editor) will not work through this API. It suits chat and question answering. To give an editor’s own agent your memory, use mcp-host.md or claude-code-hooks.md instead.

What gets remembered

Conversations that arrive through this API are saved, and awe can learn facts from them like any other chat. To label where they came from, name your app:

curl -s http://127.0.0.1:8765/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-awe-App: my-script" \
  -d '{"model":"awe-default","messages":[{"role":"user","content":"..."}]}'
  • When you do not send a conversation_id, the new conversation gets an id of the form byok:<app>:<uuid>. Facts learned from it are filed under capture:byok:<app>. Captured facts are never promoted into your pinned memory automatically.
  • The app name comes from X-awe-App, then the user field, then app. It is lowercased and cut to 24 letters, digits, _ or -.
  • A conversation_id you supply is used as it is.
  • To turn the labelling off, set AWE_BYOK_SCOPED_IDS=0 in .env. The setting in .env wins over the switch in the console.

Requests through this API do not get the console chat’s file and shell tools. See managed-chat-tools.md.

Settings

Setting in .env Default What it does
AWE_OPENAI_COMPAT_TOKEN not set When set, /v1 requires Authorization: Bearer <value>
AWE_BYOK_SCOPED_IDS 1 Label conversations from this API by app. 0 turns it off
WEB_PORT 8765 The console’s port, which is also this API’s port

The full route list

The console publishes an OpenAPI 3 document for all of its routes, including these two:

curl -s http://127.0.0.1:8765/api/docs/openapi.json

The console’s Docs & API page shows the same document in a browser.

Troubleshooting

  • 503, “not configured”: no model is chosen. Open Settings → LLM/Model in the console.
  • 401: AWE_OPENAI_COMPAT_TOKEN is set. Send it as a bearer token, or remove the line and restart.
  • Connection refused: awe is not running, or the console is on another port. Run ./start-awe.sh, and check WEB_PORT in .env.
  • 403 from a web page: browsers on other sites are blocked on purpose. Call the API from a script or a local app.