GitHub Agentic Workflows

AI Credits Specification

Version: 1.4.0
Status: Draft
Publication Date: 2026-06-09
Editor: GitHub Agentic Workflows Team
This Version: ai-credits-specification
Latest Published Version: This document


This specification defines AI Credits (AIC) as the normative inference-cost metric for GitHub Agentic Workflows (gh-aw). It specifies the required calculation model from token usage and provider pricing, the canonical models.json catalog format used to store per-model pricing inputs, and the required external references for GitHub Copilot model and billing alignment.

This section describes the status of this document at the time of publication. This is a draft specification and may be updated, replaced, or made obsolete by other documents at any time.

This document is governed by the GitHub Agentic Workflows project specifications process.

  1. Introduction
  2. Conformance
  3. AI Credits Accounting Model
  4. Pricing Catalog Format (models.json)
  5. Catalog Provisioning and Synchronization
  6. Copilot Billing Reference Requirements
  7. Reporting Requirements
  8. Compliance Testing
  9. Daily AI Credits Guardrail
  10. Per-Run AI Credits Budget
  11. Appendices
  12. References
  13. Change Log

AIC provides a single monetary-normalized metric for inference cost across supported model providers. This specification defines how conforming implementations compute AIC, how pricing data is represented, and how Copilot-specific pricing alignment is governed.

This specification covers:

  • The normative AIC unit definition and conversion rules.
  • The per-invocation and aggregated AIC calculation formulas.
  • Required models.json data structure and field semantics.
  • Requirements for how pricing catalog data is provided and mirrored in gh-aw.
  • Required references to GitHub Copilot model and billing documentation.

This specification does NOT cover:

  • GitHub Actions minutes billing.
  • ET (Effective Tokens) normalization rules.
  • Provider-side billing reconciliation and invoice dispute procedures.

The specification is designed to:

  1. Provide a testable and deterministic calculation contract.
  2. Keep pricing inputs explicit and auditable through structured catalog files.
  3. Support model-name drift through normalized lookup and prefix fallback matching.
  4. Maintain compatibility between CLI and setup runtime pricing catalogs.

Conforming implementation: Satisfies all MUST/SHALL requirements in Sections 3 through 8.

Partially conforming implementation: Computes core AIC from token usage and model pricing (Section 3) but omits one or more optional reporting or synchronization requirements.

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

  • Level 1 – Calculation: Implements AIC formulas and provider token handling (Section 3).
  • Level 2 – Catalog: Implements required models.json structure and lookup semantics (Section 4).
  • Level 3 – Operational: Implements catalog provisioning, Copilot reference alignment, and reporting requirements (Sections 5–7).

A conforming implementation MUST define:

  • 1 AIC = 0.01 USD
  • AIC = USD / 0.01

Implementations MUST support the following token classes for cost calculation when available:

  • Input tokens
  • Output tokens
  • Cache read tokens
  • Cache write tokens
  • Reasoning tokens

For a single invocation, implementations MUST compute USD as:

cost_usd =
(input_tokens × input_price_per_token) +
(output_tokens × output_price_per_token) +
(cache_read_tokens × cache_read_price_per_token) +
(cache_write_tokens × cache_write_price_per_token) +
(reasoning_tokens × reasoning_price_per_token)

A conforming implementation MUST derive AIC as:

aic = cost_usd / 0.01

If a model entry omits optional price fields, implementations MUST apply the following fallback behavior:

  • cache_read_price_per_token defaults to input_price_per_token
  • cache_write_price_per_token defaults to input_price_per_token
  • reasoning_price_per_token defaults to output_price_per_token

For providers that include cache-read tokens in total input tokens, implementations MUST subtract cache_read_tokens from input_tokens before applying input price and MUST NOT double-charge cache-read usage.

For grouped runs (for example, episodes), implementations MUST aggregate AIC by summing per-invocation AIC values.


A conforming catalog MUST be valid JSON with this structure:

{
"providers": {
"provider-name": {
"models": {
"model-id": {
"cost": {
"input": "...",
"output": "...",
"cache_read": "...",
"cache_write": "...",
"reasoning": "..."
}
}
}
}
}
}

For each model:

  • cost.input MUST be present.
  • cost.output MUST be present.
  • cost.cache_read MAY be present.
  • cost.cache_write MAY be present.
  • cost.reasoning MAY be present.

Cost values MUST be decimal numbers encoded as strings and interpreted as USD per token.

Provider keys MUST be lowercase identifiers. For Copilot-backed pricing, the canonical provider key MUST be github-copilot.

A conforming implementation MUST normalize provider and model identifiers for lookup by trimming whitespace and applying case-insensitive comparison. An implementation SHOULD support compatibility matching between punctuation variants (for example, . and _ compared to -) and provider-scoped prefix fallback.

A conforming implementation MUST recognize the following provider name aliases and normalize them to github-copilot before catalog lookup:

Input valueNormalized to
githubgithub-copilot
copilotgithub-copilot
github_modelsgithub-copilot

The github_models alias is written by the AWF proxy for Copilot engine runs and MUST be recognized so that AIC is computed and emitted for all Copilot-backed engines.


5. Catalog Provisioning and Synchronization

Section titled “5. Catalog Provisioning and Synchronization”

gh-aw implementations MUST provide synchronized pricing catalogs at:

  • pkg/cli/data/models.json
  • actions/setup/js/models.json

These files SHALL represent the same pricing dataset.

Catalog refresh processes SHOULD use normalized upstream model inventories and SHOULD validate Copilot entries against authoritative GitHub Copilot model and billing documentation.

Catalog updates MUST preserve JSON validity and MUST maintain backward-safe handling for historical model IDs that remain in the catalog but are absent from current live inventories.


Implementations and documentation that describe Copilot AIC behavior MUST reference:

These references SHOULD be treated as the external billing-alignment sources for Copilot model pricing validation.


A conforming implementation MUST expose AIC in runtime reporting outputs where cost metrics are emitted.

Implementations SHOULD provide:

  • Per-run AIC values.
  • Aggregated AIC values for grouped executions.
  • Structured output fields suitable for machine parsing.

A conformance test suite MUST include at least the following test cases:

  • T-AIC-001: Verify 1 AIC = 0.01 USD conversion.
  • T-AIC-002: Verify per-invocation AIC computation using all token classes.
  • T-AIC-003: Verify cache-read subtraction behavior for providers that include cache-read tokens in input totals.
  • T-AIC-004: Verify fallback pricing when optional cost fields are omitted.
  • T-AIC-005: Verify models.json rejects missing required fields (input, output).
  • T-AIC-006: Verify provider key normalization and github, copilot, and github_models to github-copilot mapping behavior.
  • T-AIC-007: Verify catalog mirror consistency between CLI and setup runtime paths.
  • T-AIC-008: Verify reporting outputs include per-run AIC values.
RequirementTest IDLevelStatus
Unit conversion (1 AIC = 0.01 USD)T-AIC-0011Required
Full token-class formulaT-AIC-0021Required
Cache-read non-double-charge behaviorT-AIC-0031Required
Optional price fallback behaviorT-AIC-0041Required
Catalog schema conformanceT-AIC-0052Required
Provider/model normalization behaviorT-AIC-0062Required
Mirrored catalog consistencyT-AIC-0073Required
AIC reporting visibilityT-AIC-0083Required

The daily AI Credits guardrail is a per-workflow cumulative budget limit evaluated at action runtime. It prevents a single workflow from consuming excessive AI Credits across all runs in a rolling 24-hour window. This section specifies the normative resolution order for the guardrail threshold and the mechanism by which the runtime default is resolved.

The guardrail threshold is expressed through the max-daily-ai-credits frontmatter field in the workflow YAML source. When set, a conforming compiler MUST emit the resolved threshold as the GH_AW_MAX_DAILY_AI_CREDITS environment variable in the compiled workflow YAML. The daily guardrail check step MUST gate its execution on this variable being non-empty.

A conforming implementation MUST resolve the effective daily AI Credits threshold using the following precedence (highest to lowest):

  1. Frontmatter value (max-daily-ai-credits): Resolved at compile time. Numeric values MUST be normalized to integer strings; suffix notation (K, M) MUST be expanded (e.g., 100M100000000). When present, the resolved value MUST be emitted literally as the GH_AW_MAX_DAILY_AI_CREDITS value.

  2. Imported workflow configuration (max-daily-ai-credits from imported shared workflows): Resolved at compile time using a first-wins accumulation across all imported workflows. A conforming implementation MUST apply the first usable max-daily-ai-credits value found across imports when no frontmatter value is present on the main workflow. Imported values undergo the same normalization and validation rules as frontmatter values.

  3. Runtime organization variable (vars.GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS): A GitHub Actions vars.* expression resolved at action runtime by the GitHub Actions runner. A conforming implementation MUST NOT read this variable at compile time via the process environment; it MUST instead be embedded in the compiled YAML as a GitHub Actions expression evaluated by the runner.

  4. Built-in constant default (5000): The fallback literal embedded in the GitHub Actions expression when the organization variable is unset. The value 5000 AIC represents the normative built-in default for the daily guardrail threshold.

A conforming implementation MUST NOT resolve any of these values from repository-local configuration files (e.g., aw.json).

When neither a frontmatter value nor an imported workflow configuration value is present, a conforming implementation MUST emit the following GitHub Actions expression as the GH_AW_MAX_DAILY_AI_CREDITS environment variable value in the compiled workflow:

${{ vars.GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS || '5000' }}

This expression MUST be emitted verbatim (not pre-evaluated) so that the GitHub Actions runner resolves the organization variable at workflow execution time. The '5000' fallback ensures the guardrail is active by default when the organization variable is not configured.

A max-daily-ai-credits frontmatter value of -1 MUST disable the daily guardrail. When this sentinel is present:

  • A conforming implementation MUST NOT emit GH_AW_MAX_DAILY_AI_CREDITS into the compiled workflow.
  • The daily guardrail check step MUST be skipped at runtime (its if: condition evaluates to false).

A conforming implementation MUST enforce the following at compile time:

  • Accept positive integers and positive numeric strings.
  • Accept the suffix notation K and M (case-insensitive) as multipliers (×1,000 and ×1,000,000 respectively).
  • Accept -1 as the explicit disable sentinel.
  • Accept GitHub Actions expression strings (verbatim, passed through for runtime evaluation).
  • Reject integer values below -1 with a compile-time validation error.
  • Reject non-numeric, non-expression values.
Test IDDescriptionRequirement
T-AIC-DG-001Frontmatter value emitted literally; no expression wrapper§9.3 (1)
T-AIC-DG-002No frontmatter, no imports: emitted expression is ${{ vars.GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS || '5000' }}§9.4
T-AIC-DG-003Frontmatter -1 disables guardrail; no env var emitted§9.5
T-AIC-DG-004K/M suffix values expanded in emitted literal§9.6
T-AIC-DG-005Values below -1 rejected at compile time§9.6
T-AIC-DG-006Runtime variable resolved by GitHub Actions runner, not compiler process§9.3 (3)
T-AIC-DG-007Imported workflow max-daily-ai-credits used when no frontmatter value; frontmatter takes precedence over imports§9.3 (2)
T-AIC-DG-008workflow_call event → guardrail skipped§9.8 (1)
T-AIC-DG-009repository_dispatch event → guardrail skipped§9.8 (1)
T-AIC-DG-010workflow_dispatch + absent/empty GH_AW_WORKFLOW_DISPATCH_AW_CONTEXT → guardrail skipped§9.8 (2)
T-AIC-DG-011workflow_dispatch + aw_context.event_type in slash-command types → guardrail skipped§9.8 (3)
T-AIC-DG-012workflow_dispatch + non-empty aw_context.trigger_label → guardrail skipped§9.8 (3)
T-AIC-DG-013GH_AW_HAS_SLASH_COMMAND=true + matching event → guardrail skipped§9.8 (4)
T-AIC-DG-014GH_AW_HAS_SLASH_COMMAND=true + non-matching event → guardrail enforced§9.8 (4)
T-AIC-DG-015GH_AW_HAS_LABEL_COMMAND=true + matching event → guardrail skipped§9.8 (5)
T-AIC-DG-016GH_AW_HAS_LABEL_COMMAND=true + non-matching event → guardrail enforced§9.8 (5)

The runtime MUST skip the daily AI Credits guardrail check under the conditions specified in this section. These conditions represent user-initiated or command-driven invocations where throttling would block intentional user actions rather than automated background activity.

The following environment variables govern bypass evaluation at runtime:

VariableSourcePurpose
GITHUB_EVENT_NAMEGitHub Actions runnerThe GitHub event that triggered the current workflow run
GH_AW_WORKFLOW_DISPATCH_AW_CONTEXTCentralized dispatch routerJSON payload present when the workflow was routed via workflow_dispatch; absent for direct manual triggers
GH_AW_HAS_SLASH_COMMANDgh-aw compilerSet to "true" when the compiled workflow includes a non-centralized slash command trigger
GH_AW_HAS_LABEL_COMMANDgh-aw compilerSet to "true" when the compiled workflow includes a non-centralized label command trigger

Condition 1 — Centralized or routed invocations. When GITHUB_EVENT_NAME is workflow_call or repository_dispatch, the runtime SHALL skip the guardrail. These events indicate the workflow was invoked as a reusable sub-workflow or via programmatic repository dispatch; the initiating workflow is responsible for its own daily budget enforcement.

Condition 2 — Manual workflow_dispatch without routing context. When GITHUB_EVENT_NAME is workflow_dispatch and GH_AW_WORKFLOW_DISPATCH_AW_CONTEXT is absent or empty, the runtime SHALL skip the guardrail. This condition identifies a human who explicitly triggered the workflow from the GitHub UI or GitHub CLI; blocking such a run would defeat the purpose of a manual invocation.

Condition 3 — Dispatch-routed command invocations. When GITHUB_EVENT_NAME is workflow_dispatch and GH_AW_WORKFLOW_DISPATCH_AW_CONTEXT contains a valid JSON payload that identifies a command-driven run — specifically, when aw_context.event_type is one of issue_comment, pull_request_review_comment, or discussion_comment, or when aw_context.trigger_label is a non-empty string — the runtime SHALL skip the guardrail. These are slash or label command runs routed through the centralized dispatch mechanism.

[!NOTE] When GH_AW_WORKFLOW_DISPATCH_AW_CONTEXT is present but contains malformed JSON, the runtime MUST skip the guardrail as a safe fallback, treating the run as a manual dispatch (Condition 2 semantics).

Condition 4 — Non-centralized slash-command events. When GH_AW_HAS_SLASH_COMMAND is "true" and GITHUB_EVENT_NAME is one of issue_comment, pull_request_review_comment, discussion_comment, issues, pull_request, or discussion, the runtime SHALL skip the guardrail. This condition covers slash-command triggers compiled directly into the workflow rather than routed through the centralized dispatcher.

Condition 5 — Non-centralized label-command events. When GH_AW_HAS_LABEL_COMMAND is "true" and GITHUB_EVENT_NAME is one of issues, pull_request, or discussion, the runtime SHALL skip the guardrail. This condition covers label-command triggers compiled directly into the workflow.

A conforming implementation MUST evaluate bypass conditions before checking the daily AIC total. When any bypass condition is satisfied, the implementation MUST NOT read or compare the daily AIC usage data for the current run.


The per-run AI Credits budget is a per-invocation credit limit applied by the AWF firewall to each individual workflow run. It prevents a single run from consuming excessive AI Credits regardless of daily aggregate usage. This section specifies the normative resolution order for the budget threshold and the mechanism by which the runtime default is resolved.

The budget threshold is expressed through the max-ai-credits frontmatter field in the workflow YAML source. When set, a conforming compiler MUST bake the resolved integer threshold directly into the AWF firewall configuration JSON emitted by the compiled workflow. When not set, a conforming implementation MUST resolve the threshold at action runtime using the mechanism specified in §10.4.

A conforming implementation MUST resolve the effective per-run AI Credits budget using the following precedence (highest to lowest):

  1. Frontmatter value (max-ai-credits): Resolved at compile time. Numeric values MUST be normalized to integers; suffix notation (K, M) MUST be expanded (e.g., 1M1000000). When present, the resolved integer MUST be baked into the AWF firewall config JSON at compile time.

  2. Imported workflow configuration (max-ai-credits from imported shared workflows): Resolved at compile time using a first-wins accumulation across all imported workflows. A conforming implementation MUST apply the first usable max-ai-credits value found across imports when no frontmatter value is present on the main workflow. Imported values undergo the same normalization rules as frontmatter values.

  3. Runtime organization variable (vars.GH_AW_DEFAULT_MAX_AI_CREDITS): A GitHub Actions vars.* expression resolved at action runtime by the GitHub Actions runner. A conforming implementation MUST NOT read this variable at compile time via the process environment; it MUST instead embed a GitHub Actions expression evaluated by the runner at execution time.

  4. Built-in constant default (1000): The fallback literal embedded in the GitHub Actions expression when the organization variable is unset. The value 1000 AIC represents the normative built-in default for the per-run budget.

A conforming implementation MUST NOT resolve any of these values from repository-local configuration files (e.g., aw.json).

When neither a frontmatter value nor an imported workflow configuration value is present, a conforming implementation MUST emit a runtime patch step that applies the following GitHub Actions expression to the AWF firewall configuration JSON:

${{ vars.GH_AW_DEFAULT_MAX_AI_CREDITS || '1000' }}

This expression MUST be embedded in the compiled YAML (not pre-evaluated at compile time) so that the GitHub Actions runner resolves the organization variable at workflow execution time. The '1000' fallback ensures the budget is active by default when the organization variable is not configured.

A max-ai-credits frontmatter value of -1 MUST disable the per-run budget. When this sentinel is present at runtime (via the organization variable resolving to -1), a conforming implementation MUST disable AWF budget steering and omit the maxAiCredits field from the firewall configuration.

A conforming implementation MUST enforce the following at compile time when a frontmatter value is present:

  • Accept positive integers and positive numeric strings.
  • Accept the suffix notation K and M (case-insensitive) as multipliers (×1,000 and ×1,000,000 respectively).
  • Accept -1 as the explicit disable sentinel.
  • Reject integer values below -1 with a compile-time validation error.
  • Reject non-numeric values.
Test IDDescriptionRequirement
T-AIC-PR-001Frontmatter value baked into AWF config JSON at compile time§10.3 (1)
T-AIC-PR-002No frontmatter, no imports: emitted expression is ${{ vars.GH_AW_DEFAULT_MAX_AI_CREDITS || '1000' }}§10.4
T-AIC-PR-003Org variable -1 disables budget steering at runtime§10.5
T-AIC-PR-004K/M suffix values expanded in compile-time literal§10.6
T-AIC-PR-005Values below -1 rejected at compile time§10.6
T-AIC-PR-006Runtime variable resolved by GitHub Actions runner, not compiler process§10.3 (3)
T-AIC-PR-007Imported workflow max-ai-credits used when no frontmatter value; frontmatter takes precedence over imports§10.3 (2)

This example assumes the provider bundles cache-read tokens in the reported input total, so §3.5 applies.

Given:

  • Input (raw): 1000 tokens at $0.000003/token
  • Output: 200 tokens at $0.000015/token
  • Cache read: 400 tokens at $0.0000003/token
  • Cache write: 50 tokens at $0.00000375/token
  • Reasoning: 25 tokens at $0.000015/token

Step 1 — Apply §3.5: net input = 1000 − 400 = 600 tokens

Step 2 — Per-class cost:

input: 600 × 0.000003 = 0.0018000
output: 200 × 0.000015 = 0.0030000
cache_read: 400 × 0.0000003 = 0.0001200
cache_write: 50 × 0.00000375 = 0.0001875
reasoning: 25 × 0.000015 = 0.0003750

Result:

cost_usd = 0.0054825
aic = 0.54825

Conforming implementations SHOULD surface explicit validation errors for:

  • Invalid models.json structure.
  • Non-numeric cost values.
  • Missing required model cost fields.
  • Unknown provider/model pairs with no fallback match.

Appendix C: Security and Integrity Considerations

Section titled “Appendix C: Security and Integrity Considerations”

Pricing catalogs are configuration inputs. Implementations SHOULD:

  • Treat catalog updates as controlled changes.
  • Validate and review catalog source provenance.
  • Avoid silently mutating cost values at runtime.


  • Added: §9.8 — Guardrail Bypass Conditions. Specifies the five normative runtime conditions under which a conforming implementation MUST skip the daily AI Credits guardrail: (1) workflow_call or repository_dispatch events; (2) manual workflow_dispatch without routing context; (3) dispatch-routed slash or label command invocations; (4) non-centralized slash-command events with GH_AW_HAS_SLASH_COMMAND=true; (5) non-centralized label-command events with GH_AW_HAS_LABEL_COMMAND=true.
  • Updated: §9.7 — Added compliance tests T-AIC-DG-008 through T-AIC-DG-016 covering each bypass condition and its negative case.
  • Updated: Version and publication metadata to 1.4.0.
  • Updated: §9.3 — Expanded the Daily AI Credits Guardrail resolution order from three levels to four. Added “Imported workflow configuration” as the second priority (between frontmatter and the runtime org variable), documenting that a conforming implementation MUST apply the first usable max-daily-ai-credits value found across imported shared workflows when no frontmatter value is present on the main workflow.
  • Updated: §9.4 — Clarified that the runtime expression is emitted only when neither frontmatter nor imported config provides a value.
  • Updated: §9.7 — Added compliance test T-AIC-DG-007 asserting imported workflow max-daily-ai-credits resolution.
  • Updated: §10.3 — Expanded the Per-Run AI Credits Budget resolution order from three levels to four. Added “Imported workflow configuration” as the second priority, documenting that a conforming implementation MUST apply the first usable max-ai-credits value found across imported shared workflows when no frontmatter value is present.
  • Updated: §10.4 — Clarified that the runtime patch step is emitted only when neither frontmatter nor imported config provides a value.
  • Updated: §10.7 — Added compliance test T-AIC-PR-007 asserting imported workflow max-ai-credits resolution.
  • Updated: Version and publication metadata to 1.3.0.
  • Added: Section 10 — Per-Run AI Credits Budget. Specifies the normative three-level resolution order (frontmatter → vars.GH_AW_DEFAULT_MAX_AI_CREDITS at runtime → built-in constant 1000) and the required runtime patch mechanism emitted by conforming compilers when no frontmatter value is set.
  • Added: §10.7 compliance test matrix (T-AIC-PR-001 through T-AIC-PR-006).
  • Updated: Table of contents and publication metadata to 1.2.0.
  • Added: Section 9 — Daily AI Credits Guardrail. Specifies the normative three-level resolution order (frontmatter → vars.GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS at runtime → built-in constant 5000) and the required GitHub Actions expression form emitted by conforming compilers.
  • Added: §9.7 compliance test matrix (T-AIC-DG-001 through T-AIC-DG-006).
  • Updated: Table of contents and publication metadata to 1.1.0.
  • Added initial AI Credits (AIC) normative definition and formulas.
  • Added canonical models.json format and synchronization requirements.
  • Added Copilot billing reference requirements and compliance test matrix.

Copyright 2026 GitHub. All rights reserved.