Skip to content

OpenAI API Agent

The openai-api agent calls the OpenAI API directly to generate text responses within your workflow. It requires no local binary — just an API key. This makes it ideal for CI/CD pipelines, headless servers, and environments where installing CLI tools isn’t practical.

The agent supports both standard and gate phases. In standard phases it produces a natural-language response based on the role prompt and upstream context. In gate phases it evaluates the pipeline state and produces a verdict (PASS, ROUTE, or ESCALATE).


- name: triage
agent: openai-api
role: classifier
model: gpt-4o
depends_on: [fetch-ticket]

The openai-api agent supports two phase types:

Phase TypeDescription
standardGenerates a text response from the role prompt and upstream handoff context
gateEvaluates pipeline state and produces a verdict: PASS, ROUTE, or ESCALATE
FieldTypeRequiredDescription
namestringYesUnique phase name within the workflow
typestringNo"standard" (default) or "gate"
agentstringYesMust be "openai-api"
rolestringYesRole file name (without .md) from .cliq/roles/
depends_onstring[]NoUpstream phases that must complete before this phase runs
modelstringNoModel override. Default: "gpt-4o"

The model field is specified on the phase declaration and overrides the default model (gpt-4o) for that phase only.


Configure under agents.openai-api via cliq settings:

KeyRequiredDefaultDescription
agents.openai-api.api_keyYesOpenAI API key

The openai-api agent produces a minimal handoff envelope with the LLM response as text:

{
"data": null,
"text": "The agent's natural language response and summary of work performed."
}

The data field is always null — all meaningful output is in the text field, which contains the model’s complete response shaped by the role prompt and upstream context.

In gate phases, the agent’s text output is parsed for a verdict:

VerdictMeaning
PASSPipeline continues to the next phase
ROUTEPipeline branches to a specified alternative phase
ESCALATEPipeline halts and requests human intervention

Example: Fast triage in a support pipeline

Section titled “Example: Fast triage in a support pipeline”

Use GPT-4o to quickly classify and route incoming requests before handing off to a specialized agent.

phases:
- name: triage
type: gate
agent: openai-api
role: triage-router
- name: handle-bug
agent: cursor
role: developer
depends_on: [triage]
- name: handle-question
agent: openai-api
role: support-responder
depends_on: [triage]

Use the default GPT-4o for fast drafting and upgrade to o3 for complex reasoning steps.

phases:
- name: research
agent: openai-api
role: researcher
- name: synthesize
agent: openai-api
role: analyst
model: o3
depends_on: [research]
- name: review
type: gate
agent: openai-api
role: reviewer
depends_on: [synthesize]

A lightweight validation pipeline that runs entirely via API calls — suitable for GitHub Actions or any CI system.

phases:
- name: check-conventions
agent: openai-api
role: linter
- name: check-security
agent: openai-api
role: security-reviewer
depends_on: [check-conventions]
- name: approve
type: gate
agent: openai-api
role: approver
depends_on: [check-security]
- name: finalize
agent: git
action: create_pr
depends_on: [approve]

  1. Go to https://platform.openai.com/api-keys
  2. Click Create new secret key and name it (e.g., cliq)
  3. Copy the generated key
Terminal window
echo $OPENAI_API_KEY | cliq settings agents.openai-api.api_key --stdin --global
cliq doctor agent openai-api

cliq doctor agent openai-api checks:

  • agents.openai-api.api_key is configured in settings
  • The API key can authenticate against the OpenAI API