API Reference
Ad-hoc generation
POST /runtime/execute and /runtime/stream — run a generation by specifying the provider, model, and messages on each request.
Run a generation where the client supplies everything: the provider, the model, and the full message list. Use this when the caller owns the configuration; for configuration managed by your team, use a deployed assistant instead.
POST /runtime/execute
Runs one non-streaming generation and returns the complete result.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
providerName | string | yes | Target provider, e.g. openai or anthropic. |
model | string | yes | Provider model identifier, e.g. gpt-4o. |
messages | array | yes | Ordered conversation; at least one message. |
messages[].role | system | user | assistant | yes | Message author role. |
messages[].content | string | yes | Message text. |
config | object | no | Generation settings (below); defaults to {}. |
config
| Field | Type | Description |
|---|---|---|
temperature | number | Sampling temperature. |
maxOutputTokens | number | Cap on generated tokens. |
responseFormat | text | json | Force plain text or JSON output. |
timeoutMs | number | Per-generation timeout. |
maxRetries | number | Provider retry budget. |
Example request
curl https://api.polimorf.app/runtime/execute \
-H "Authorization: Bearer $POLIMORF_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"providerName": "openai",
"model": "gpt-4o",
"messages": [
{ "role": "system", "content": "You are a concise assistant." },
{ "role": "user", "content": "Explain embeddings in one sentence." }
],
"config": { "temperature": 0.2, "maxOutputTokens": 200 }
}'Response
{
"message": { "role": "assistant", "content": "An embedding is a…" },
"finishReason": "stop",
"usage": { "inputTokens": 24, "outputTokens": 18, "totalTokens": 42 }
}| Field | Type | Description |
|---|---|---|
message | object | The generated message (role, content). |
finishReason | string | stop, length, tool_calls, content_filter, or error. |
usage | object | Token accounting: inputTokens, outputTokens, totalTokens. |
With the SDK
const result = await client.runtime.execute({
providerName: 'openai',
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Explain embeddings in one sentence.' }],
config: { temperature: 0.2 },
});Streaming
POST /runtime/stream
Identical request body to /runtime/execute, but the response is a
Server-Sent Events stream of delta → usage → done
events (or a terminal error).
for await (const event of client.runtime.stream({
providerName: 'openai',
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Write a haiku about the sea.' }],
})) {
if (event.type === 'delta') process.stdout.write(event.content);
}See Streaming for the full event contract and cancellation.