> ## Documentation Index
> Fetch the complete documentation index at: https://docs.errorbar.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Export the environment bundle

> The grader, packaged: reward spec, each judge's calibration certificate, deterministic assertions, declared env tools (names only — never endpoint URLs or auth), the session's stored tasks, the anchor and its hold state, and adapter snippets for TRL and verifiers. Signed with the same key as eval evidence bundles; verify with `POST /v1/verify`. `format=tasks` returns just `tasks.jsonl` — one task per line in the shape `rl/omnia_grpo/tasks.py` and OpenEnv-style loaders read.



## OpenAPI

````yaml /openapi.json get /v1/reward/sessions/{id}/environment
openapi: 3.1.0
info:
  title: errorbar Management API
  description: >-
    The management API behind the improvement loop: capture and setup, request
    logs and datasets, grades (labels), judges (criteria), evals and deploy
    gates, fine-tuning and reinforcement learning, dedicated GPU endpoints, and
    model aliases and versions. Authenticated with a workspace API key
    (sk_sovereign_...). The inference API (chat, embeddings, rerank, responses)
    is OpenAI-compatible and documented separately.


    Responses are snake_case, list endpoints on the loop products use the
    {"object": "list", "data": [...]} envelope, and refusals use the same nested
    error shape the gateway emits: {"error": {"message", "type", "code"}}.
    Request bodies on the loop products (logs, labels, criteria, evals,
    datasets, aliases) are snake_case; the training and infrastructure products
    (fine-tuning, GRPO, environment tools, dedicated, model-version adoption)
    validate camelCase bodies, and each schema below says which it is. Endpoints
    that spend money require a key minted by a workspace owner or admin and
    return 403 otherwise.
  version: 1.0.0
servers:
  - url: https://gateway.errorbar.ai
    description: Production
  - url: https://www.errorbar.ai/api
    description: Control plane (also served at this base URL)
security:
  - bearerAuth: []
tags:
  - name: Certified reward
    description: >-
      The certified reward for your own trainer: sessions with judge
      certificates, scoring with a ledger-true kill switch, and the mid-run
      anchor that holds a run when the reward diverges from an independent
      judge.
paths:
  /v1/reward/sessions/{id}/environment:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
    get:
      tags:
        - Certified reward
      summary: Export the environment bundle
      description: >-
        The grader, packaged: reward spec, each judge's calibration certificate,
        deterministic assertions, declared env tools (names only — never
        endpoint URLs or auth), the session's stored tasks, the anchor and its
        hold state, and adapter snippets for TRL and verifiers. Signed with the
        same key as eval evidence bundles; verify with `POST /v1/verify`.
        `format=tasks` returns just `tasks.jsonl` — one task per line in the
        shape `rl/omnia_grpo/tasks.py` and OpenEnv-style loaders read.
      operationId: getRewardEnvironment
      parameters:
        - name: format
          in: query
          required: false
          schema:
            type: string
            enum:
              - bundle
              - tasks
          description: '`bundle` (default, JSON) or `tasks` (JSONL).'
      responses:
        '200':
          description: The signed bundle, or tasks.jsonl when format=tasks.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RewardEnvironmentBundle'
            application/jsonl:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    RewardEnvironmentBundle:
      type: object
      description: >-
        Signed (HS256 over canonical JSON; `signature: null` + `unsigned: true`
        when the deployment has no signing key).
      properties:
        bundle_v:
          type: integer
        kind:
          type: string
          enum:
            - errorbar.reward_environment
        issued_at:
          type: string
          format: date-time
        session:
          type: object
          properties:
            id:
              type: string
            status:
              type: string
            agentic:
              type: boolean
            label:
              type:
                - string
                - 'null'
            created_at:
              type: string
            expires_at:
              type: string
            held:
              type: boolean
            pinned_step:
              type:
                - string
                - 'null'
        reward:
          $ref: '#/components/schemas/RewardSpec'
        grader:
          type: object
          properties:
            criteria:
              type: array
              items:
                type: object
            certificates:
              type: array
              items:
                type: object
              description: One signed judge certificate per reward criterion.
            assertions:
              type: array
              items:
                type: object
        anchor:
          type:
            - object
            - 'null'
        tools:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              read_only:
                type: boolean
              max_calls_per_episode:
                type:
                  - integer
                  - 'null'
        tasks:
          type: array
          items:
            $ref: '#/components/schemas/RewardTask'
        task_count:
          type: integer
        endpoints:
          type: object
        adapters:
          type: object
          properties:
            trl:
              type: string
            verifiers:
              type: string
        signature:
          type:
            - object
            - 'null'
    RewardSpec:
      oneOf:
        - type: object
          required:
            - mode
            - criterionId
          properties:
            mode:
              type: string
              enum:
                - single
            criterionId:
              type: string
              description: A calibrated judge (TPR and TNR ≥ 0.9, not drift-flagged).
        - type: object
          required:
            - mode
            - criterionIds
          properties:
            mode:
              type: string
              enum:
                - compositional
            criterionIds:
              type: array
              items:
                type: string
              minItems: 2
              description: >-
                Two or more calibrated judges (each ≥ 0.75); the composite grade
                is their mean with any assertions.
            assertions:
              type: array
              items:
                type: object
              description: >-
                Deterministic components (json_schema, regex_match, tool_called,
                exec …), 0/1 each.
    RewardTask:
      type: object
      required:
        - goal
      properties:
        goal:
          type: array
          items:
            type: object
            properties:
              role:
                type: string
              content:
                type: string
          description: The task as chat messages (1..50).
        image:
          type: string
          description: Optional sandbox image.
        verifier:
          type: array
          items:
            type: object
            properties:
              command:
                type: string
              timeout_sec:
                type: integer
          description: >-
            Per-task exec verifiers (≤ 8), run server-side as deterministic
            reward components.
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              description: >-
                invalid_request_error, insufficient_quota, rate_limit_error, or
                api_error.
            code:
              type: string
              description: >-
                Machine-stable cause, e.g. invalid_api_key, not_found,
                insufficient_permissions, precondition_failed.
          required:
            - message
            - type
            - code
      description: >-
        Every refusal — gateway and management API alike — uses this one
        envelope.
  responses:
    BadRequest:
      description: Malformed request or invalid field.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing, malformed, or revoked API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: Invalid API key
              type: invalid_request_error
              code: invalid_api_key
    Forbidden:
      description: The key lacks the required owner/admin permission.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The resource does not exist in your workspace.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your workspace API key, e.g. `sk_sovereign_...`, sent as `Authorization:
        Bearer <key>`.

````