Skip to content

Commit 7911f58

Browse files
committed
docs: document token usage outputs and add usage examples
Made-with: Cursor
1 parent ccab430 commit 7911f58

1 file changed

Lines changed: 45 additions & 3 deletions

File tree

README.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,12 @@ See [Protecting your `OPENAI_API_KEY`](./docs/security.md#protecting-your-openai
134134

135135
## Outputs
136136

137-
| Name | Description |
138-
| --------------- | --------------------------------------- |
139-
| `final-message` | Final message returned by `codex exec`. |
137+
| Name | Description |
138+
| --------------------- | ----------------------------------------------------------------------------- |
139+
| `final-message` | Final message returned by `codex exec`. |
140+
| `input-tokens` | Total input tokens consumed by the run (empty string if unavailable). |
141+
| `output-tokens` | Total output tokens consumed by the run (empty string if unavailable). |
142+
| `cached-input-tokens` | Total cached input tokens consumed by the run (empty string if unavailable). |
140143

141144
As we saw in the example above, we took the `final-message` output of the `run_codex` step and made it an output of the `codex` job in the workflow:
142145

@@ -148,6 +151,45 @@ jobs:
148151
final_message: ${{ steps.run_codex.outputs.final-message }}
149152
```
150153

154+
### Using token outputs
155+
156+
Log token usage or enforce a budget in a downstream step:
157+
158+
```yaml
159+
- uses: openai/codex-action@v1
160+
id: codex
161+
with:
162+
prompt: "Fix the failing tests"
163+
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
164+
165+
- name: Log token usage
166+
run: |
167+
echo "Input tokens: ${{ steps.codex.outputs.input-tokens }}"
168+
echo "Output tokens: ${{ steps.codex.outputs.output-tokens }}"
169+
echo "Cached tokens: ${{ steps.codex.outputs.cached-input-tokens }}"
170+
```
171+
172+
To track costs across runs, forward the token counts to a cost dashboard.
173+
[AgentMeter](https://agentmeter.app) is a GitHub-native option built for this:
174+
175+
```yaml
176+
- uses: openai/codex-action@v1
177+
id: codex
178+
with:
179+
prompt: "..."
180+
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
181+
182+
- uses: AgentMeter/agentmeter-action@v1
183+
with:
184+
api_key: ${{ secrets.AGENTMETER_API_KEY }}
185+
model: gpt-5.3-codex
186+
engine: codex
187+
input_tokens: ${{ steps.codex.outputs.input-tokens }}
188+
output_tokens: ${{ steps.codex.outputs.output-tokens }}
189+
cache_read_tokens: ${{ steps.codex.outputs.cached-input-tokens }}
190+
status: ${{ job.status }}
191+
```
192+
151193
## Additional tips
152194

153195
- Run this action after `actions/checkout@v5` so Codex has access to your repository contents.

0 commit comments

Comments
 (0)