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

# Add a connection: OpenCode auth file

> Stores a new opencode_auth_file connection under its name, leaving every other connection in place.

Use this tool when you need to:
- Connect the providers OpenCode is signed in to on the caller's machine, from its auth.json, so the caller's OpenCode tasks can run on them
- Add another OpenCode auth file beside one the caller already holds, under its own name

Examples:
- POST /connections/opencode-auth-file {"name": "Laptop OpenCode", "contents": "{\"anthropic\": {\"type\": \"api\", \"key\": \"sk-ant-api03-abcdefghij\"}}"}

Hints:
- name is required: 1 to 100 characters on one line, with no space, tab, form feed or carriage return at either end; the schema answers 422 otherwise, and a name it admits is stored as sent.
- contents is required: the caller's ~/.local/share/opencode/auth.json verbatim, a JSON object of unique provider ids, each entry of type api (with key), oauth (with access, refresh and expires) or wellknown (with key and token) as OpenCode writes it. The schema answers 422 for empty contents and the handler's vendor-format check 422 for any other file it refuses, neither with a code.
- Answers 201 with the connection: option opencode_auth_file, id, name, providers (the file's provider ids, sorted) and reauth null, never the file. It becomes the OpenCode default when the caller has none; a default the caller has stays.
- Use addOpenrouterApiKeyConnection instead for an OpenRouter API key alone, reconnectConnection to replace the file of a connection the caller holds and keep its id, and setDefaultConnection to make it the default.
- Any signed-in user may call it for themselves; through a platform API key pinned to an org where the caller is a viewer or billing member it is refused with 403 org_role_insufficient, and an agent host's grant with 403 agent_host_route_not_allowed.
- Refused with 409 connection_name_taken when the caller already uses the name for an OpenCode auth file.



## OpenAPI

````yaml api-reference/openapi.json POST /connections/opencode-auth-file
openapi: 3.1.0
info:
  title: Aether API
  version: 0.1.0
servers:
  - url: https://api.runaether.dev
security:
  - bearerAuth: []
paths:
  /connections/opencode-auth-file:
    post:
      tags:
        - connections
      summary: 'Add a connection: OpenCode auth file'
      description: >-
        Stores a new opencode_auth_file connection under its name, leaving every
        other connection in place.


        Use this tool when you need to:

        - Connect the providers OpenCode is signed in to on the caller's
        machine, from its auth.json, so the caller's OpenCode tasks can run on
        them

        - Add another OpenCode auth file beside one the caller already holds,
        under its own name


        Examples:

        - POST /connections/opencode-auth-file {"name": "Laptop OpenCode",
        "contents": "{\"anthropic\": {\"type\": \"api\", \"key\":
        \"sk-ant-api03-abcdefghij\"}}"}


        Hints:

        - name is required: 1 to 100 characters on one line, with no space, tab,
        form feed or carriage return at either end; the schema answers 422
        otherwise, and a name it admits is stored as sent.

        - contents is required: the caller's ~/.local/share/opencode/auth.json
        verbatim, a JSON object of unique provider ids, each entry of type api
        (with key), oauth (with access, refresh and expires) or wellknown (with
        key and token) as OpenCode writes it. The schema answers 422 for empty
        contents and the handler's vendor-format check 422 for any other file it
        refuses, neither with a code.

        - Answers 201 with the connection: option opencode_auth_file, id, name,
        providers (the file's provider ids, sorted) and reauth null, never the
        file. It becomes the OpenCode default when the caller has none; a
        default the caller has stays.

        - Use addOpenrouterApiKeyConnection instead for an OpenRouter API key
        alone, reconnectConnection to replace the file of a connection the
        caller holds and keep its id, and setDefaultConnection to make it the
        default.

        - Any signed-in user may call it for themselves; through a platform API
        key pinned to an org where the caller is a viewer or billing member it
        is refused with 403 org_role_insufficient, and an agent host's grant
        with 403 agent_host_route_not_allowed.

        - Refused with 409 connection_name_taken when the caller already uses
        the name for an OpenCode auth file.
      operationId: addOpencodeAuthFileConnection
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddOpencodeAuthFileConnectionRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Connection'
          description: Created
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionsErrorResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionsErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrgAuthorizationErrorResponse'
          description: Forbidden
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionsErrorResponse'
          description: Conflict
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionsErrorResponse'
          description: Gone
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionsErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionsErrorResponse'
          description: Internal Server Error
components:
  schemas:
    AddOpencodeAuthFileConnectionRequest:
      additionalProperties: false
      properties:
        contents:
          description: Your ~/.local/share/opencode/auth.json, verbatim.
          minLength: 1
          type: string
        name:
          description: >-
            The connection's name: unique among your connections of its option,
            without leading or trailing spaces.
          maxLength: 100
          minLength: 1
          pattern: ^\S(.*\S)?$
          type: string
      required:
        - name
        - contents
      type: object
    Connection:
      description: >-
        One connection you hold, a variant per option: which credential it
        holds, qualified by its vendor. reauth is null while the stored
        credential works.
      discriminator:
        mapping:
          anthropic_api_key: '#/components/schemas/AnthropicApiKeyConnection'
          chatgpt_host_plan: '#/components/schemas/ChatgptHostPlanConnection'
          chatgpt_plan: '#/components/schemas/ChatgptPlanConnection'
          claude_plan: '#/components/schemas/ClaudePlanConnection'
          openai_api_key: '#/components/schemas/OpenaiApiKeyConnection'
          opencode_auth_file: '#/components/schemas/OpencodeAuthFileConnection'
          openrouter_api_key: '#/components/schemas/OpenrouterApiKeyConnection'
        propertyName: option
      oneOf:
        - $ref: '#/components/schemas/ClaudePlanConnection'
        - $ref: '#/components/schemas/AnthropicApiKeyConnection'
        - $ref: '#/components/schemas/ChatgptPlanConnection'
        - $ref: '#/components/schemas/ChatgptHostPlanConnection'
        - $ref: '#/components/schemas/OpenaiApiKeyConnection'
        - $ref: '#/components/schemas/OpenrouterApiKeyConnection'
        - $ref: '#/components/schemas/OpencodeAuthFileConnection'
    ConnectionsErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - aether_inference_unavailable
            - aether_inference_unserved
            - agent_credential_unreadable
            - agent_host_account_deleting
            - agent_host_command_not_found
            - agent_host_creation_disabled
            - agent_host_exists
            - agent_host_illegal_transition
            - agent_host_not_allowlisted
            - agent_host_not_found
            - agent_host_other_provider_app
            - agent_host_project_not_eligible
            - agent_host_provisioning_failed
            - agent_host_state_changed
            - agent_host_wake_failed
            - agent_line_unavailable
            - bad_gateway
            - bad_request
            - cli_upgrade_required
            - client_outdated
            - conflict
            - connection_account_held
            - connection_agent_only
            - connection_harness_mismatch
            - connection_is_default
            - connection_name_taken
            - connection_not_found
            - connection_option_mismatch
            - connection_runs_agent
            - connection_runs_profiles
            - device_auth_not_found
            - fallback_is_own_connection
            - forbidden
            - gateway_timeout
            - gone
            - internal_error
            - line_exists
            - line_not_found
            - line_not_imessage
            - method_not_allowed
            - no_default_connection
            - not_acceptable
            - not_found
            - not_implemented
            - payment_required
            - precondition_failed
            - rate_limited
            - request_canceled
            - request_timeout
            - request_too_large
            - service_unavailable
            - unauthenticated
            - unsupported_media_type
            - validation_failed
            - whatsapp_not_enabled
          minLength: 1
          type: string
        error:
          minLength: 1
          type: string
        errors:
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
      required:
        - error
        - code
      type: object
    OrgAuthorizationErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - org_membership_required
            - org_role_insufficient
            - org_suspended
            - account_deleting
            - agent_host_route_not_allowed
            - credential_kind_not_admitted
            - grant_scope_insufficient
          type: string
        error:
          minLength: 1
          type: string
      required:
        - error
        - code
      type: object
    AnthropicApiKeyConnection:
      additionalProperties: false
      description: An Anthropic API key.
      properties:
        id:
          format: uuid
          type: string
        key_suffix:
          description: The key's last four characters, for a key of at least eight.
          minLength: 1
          type: string
        limits:
          description: >-
            The vendor limits this connection has spent, excluding markers whose
            reset time has passed.
          items:
            discriminator:
              mapping:
                credits: '#/components/schemas/ConnectionCreditsLimit'
                model: '#/components/schemas/ConnectionModelLimit'
                session: '#/components/schemas/ConnectionSessionLimit'
                usage: '#/components/schemas/ConnectionUsageLimit'
                weekly: '#/components/schemas/ConnectionWeeklyLimit'
              propertyName: scope
            oneOf:
              - $ref: '#/components/schemas/ConnectionSessionLimit'
              - $ref: '#/components/schemas/ConnectionWeeklyLimit'
              - $ref: '#/components/schemas/ConnectionModelLimit'
              - $ref: '#/components/schemas/ConnectionCreditsLimit'
              - $ref: '#/components/schemas/ConnectionUsageLimit'
          type: array
        name:
          description: >-
            The name you gave the connection, unique among your connections of
            its option.
          minLength: 1
          type: string
        option:
          enum:
            - anthropic_api_key
          type: string
        profiles:
          description: The agent profiles that run on the connection.
          items:
            $ref: '#/components/schemas/ConnectionProfile'
          type: array
        reauth:
          anyOf:
            - $ref: '#/components/schemas/ConnectionReauth'
            - type: 'null'
      required:
        - option
        - id
        - name
        - reauth
      type: object
    ChatgptHostPlanConnection:
      additionalProperties: false
      description: >-
        The ChatGPT login your agent did on its own host. Read-only: your agent
        signs in on its host, so no operation adds or reconnects it, and only
        your agent runs on it.
      properties:
        email:
          description: The ChatGPT account's email, when its token names one.
          minLength: 1
          type: string
        id:
          format: uuid
          type: string
        limits:
          description: >-
            The vendor limits this connection has spent, excluding markers whose
            reset time has passed.
          items:
            discriminator:
              mapping:
                credits: '#/components/schemas/ConnectionCreditsLimit'
                model: '#/components/schemas/ConnectionModelLimit'
                session: '#/components/schemas/ConnectionSessionLimit'
                usage: '#/components/schemas/ConnectionUsageLimit'
                weekly: '#/components/schemas/ConnectionWeeklyLimit'
              propertyName: scope
            oneOf:
              - $ref: '#/components/schemas/ConnectionSessionLimit'
              - $ref: '#/components/schemas/ConnectionWeeklyLimit'
              - $ref: '#/components/schemas/ConnectionModelLimit'
              - $ref: '#/components/schemas/ConnectionCreditsLimit'
              - $ref: '#/components/schemas/ConnectionUsageLimit'
          type: array
        name:
          description: >-
            The name you gave the connection, unique among your connections of
            its option.
          minLength: 1
          type: string
        option:
          enum:
            - chatgpt_host_plan
          type: string
        profiles:
          description: The agent profiles that run on the connection.
          items:
            $ref: '#/components/schemas/ConnectionProfile'
          type: array
        reauth:
          anyOf:
            - $ref: '#/components/schemas/ConnectionReauth'
            - type: 'null'
      required:
        - option
        - id
        - name
        - reauth
      type: object
    ChatgptPlanConnection:
      additionalProperties: false
      description: A ChatGPT plan's tokens.
      properties:
        email:
          description: The ChatGPT account's email, when its token names one.
          minLength: 1
          type: string
        id:
          format: uuid
          type: string
        limits:
          description: >-
            The vendor limits this connection has spent, excluding markers whose
            reset time has passed.
          items:
            discriminator:
              mapping:
                credits: '#/components/schemas/ConnectionCreditsLimit'
                model: '#/components/schemas/ConnectionModelLimit'
                session: '#/components/schemas/ConnectionSessionLimit'
                usage: '#/components/schemas/ConnectionUsageLimit'
                weekly: '#/components/schemas/ConnectionWeeklyLimit'
              propertyName: scope
            oneOf:
              - $ref: '#/components/schemas/ConnectionSessionLimit'
              - $ref: '#/components/schemas/ConnectionWeeklyLimit'
              - $ref: '#/components/schemas/ConnectionModelLimit'
              - $ref: '#/components/schemas/ConnectionCreditsLimit'
              - $ref: '#/components/schemas/ConnectionUsageLimit'
          type: array
        name:
          description: >-
            The name you gave the connection, unique among your connections of
            its option.
          minLength: 1
          type: string
        option:
          enum:
            - chatgpt_plan
          type: string
        profiles:
          description: The agent profiles that run on the connection.
          items:
            $ref: '#/components/schemas/ConnectionProfile'
          type: array
        reauth:
          anyOf:
            - $ref: '#/components/schemas/ConnectionReauth'
            - type: 'null'
      required:
        - option
        - id
        - name
        - reauth
      type: object
    ClaudePlanConnection:
      additionalProperties: false
      description: A Claude plan's setup token.
      properties:
        id:
          format: uuid
          type: string
        limits:
          description: >-
            The vendor limits this connection has spent, excluding markers whose
            reset time has passed.
          items:
            discriminator:
              mapping:
                credits: '#/components/schemas/ConnectionCreditsLimit'
                model: '#/components/schemas/ConnectionModelLimit'
                session: '#/components/schemas/ConnectionSessionLimit'
                usage: '#/components/schemas/ConnectionUsageLimit'
                weekly: '#/components/schemas/ConnectionWeeklyLimit'
              propertyName: scope
            oneOf:
              - $ref: '#/components/schemas/ConnectionSessionLimit'
              - $ref: '#/components/schemas/ConnectionWeeklyLimit'
              - $ref: '#/components/schemas/ConnectionModelLimit'
              - $ref: '#/components/schemas/ConnectionCreditsLimit'
              - $ref: '#/components/schemas/ConnectionUsageLimit'
          type: array
        name:
          description: >-
            The name you gave the connection, unique among your connections of
            its option.
          minLength: 1
          type: string
        option:
          enum:
            - claude_plan
          type: string
        profiles:
          description: The agent profiles that run on the connection.
          items:
            $ref: '#/components/schemas/ConnectionProfile'
          type: array
        reauth:
          anyOf:
            - $ref: '#/components/schemas/ConnectionReauth'
            - type: 'null'
      required:
        - option
        - id
        - name
        - reauth
      type: object
    OpenaiApiKeyConnection:
      additionalProperties: false
      description: An OpenAI API key.
      properties:
        id:
          format: uuid
          type: string
        key_suffix:
          description: The key's last four characters, for a key of at least eight.
          minLength: 1
          type: string
        limits:
          description: >-
            The vendor limits this connection has spent, excluding markers whose
            reset time has passed.
          items:
            discriminator:
              mapping:
                credits: '#/components/schemas/ConnectionCreditsLimit'
                model: '#/components/schemas/ConnectionModelLimit'
                session: '#/components/schemas/ConnectionSessionLimit'
                usage: '#/components/schemas/ConnectionUsageLimit'
                weekly: '#/components/schemas/ConnectionWeeklyLimit'
              propertyName: scope
            oneOf:
              - $ref: '#/components/schemas/ConnectionSessionLimit'
              - $ref: '#/components/schemas/ConnectionWeeklyLimit'
              - $ref: '#/components/schemas/ConnectionModelLimit'
              - $ref: '#/components/schemas/ConnectionCreditsLimit'
              - $ref: '#/components/schemas/ConnectionUsageLimit'
          type: array
        name:
          description: >-
            The name you gave the connection, unique among your connections of
            its option.
          minLength: 1
          type: string
        option:
          enum:
            - openai_api_key
          type: string
        profiles:
          description: The agent profiles that run on the connection.
          items:
            $ref: '#/components/schemas/ConnectionProfile'
          type: array
        reauth:
          anyOf:
            - $ref: '#/components/schemas/ConnectionReauth'
            - type: 'null'
      required:
        - option
        - id
        - name
        - reauth
      type: object
    OpencodeAuthFileConnection:
      additionalProperties: false
      description: An OpenCode auth file.
      properties:
        id:
          format: uuid
          type: string
        limits:
          description: >-
            The vendor limits this connection has spent, excluding markers whose
            reset time has passed.
          items:
            discriminator:
              mapping:
                credits: '#/components/schemas/ConnectionCreditsLimit'
                model: '#/components/schemas/ConnectionModelLimit'
                session: '#/components/schemas/ConnectionSessionLimit'
                usage: '#/components/schemas/ConnectionUsageLimit'
                weekly: '#/components/schemas/ConnectionWeeklyLimit'
              propertyName: scope
            oneOf:
              - $ref: '#/components/schemas/ConnectionSessionLimit'
              - $ref: '#/components/schemas/ConnectionWeeklyLimit'
              - $ref: '#/components/schemas/ConnectionModelLimit'
              - $ref: '#/components/schemas/ConnectionCreditsLimit'
              - $ref: '#/components/schemas/ConnectionUsageLimit'
          type: array
        name:
          description: >-
            The name you gave the connection, unique among your connections of
            its option.
          minLength: 1
          type: string
        option:
          enum:
            - opencode_auth_file
          type: string
        profiles:
          description: The agent profiles that run on the connection.
          items:
            $ref: '#/components/schemas/ConnectionProfile'
          type: array
        providers:
          description: The model providers the auth file signs in to.
          items:
            minLength: 1
            type: string
          type: array
        reauth:
          anyOf:
            - $ref: '#/components/schemas/ConnectionReauth'
            - type: 'null'
      required:
        - option
        - id
        - name
        - reauth
        - providers
      type: object
    OpenrouterApiKeyConnection:
      additionalProperties: false
      description: An OpenRouter API key.
      properties:
        id:
          format: uuid
          type: string
        key_suffix:
          description: The key's last four characters, for a key of at least eight.
          minLength: 1
          type: string
        limits:
          description: >-
            The vendor limits this connection has spent, excluding markers whose
            reset time has passed.
          items:
            discriminator:
              mapping:
                credits: '#/components/schemas/ConnectionCreditsLimit'
                model: '#/components/schemas/ConnectionModelLimit'
                session: '#/components/schemas/ConnectionSessionLimit'
                usage: '#/components/schemas/ConnectionUsageLimit'
                weekly: '#/components/schemas/ConnectionWeeklyLimit'
              propertyName: scope
            oneOf:
              - $ref: '#/components/schemas/ConnectionSessionLimit'
              - $ref: '#/components/schemas/ConnectionWeeklyLimit'
              - $ref: '#/components/schemas/ConnectionModelLimit'
              - $ref: '#/components/schemas/ConnectionCreditsLimit'
              - $ref: '#/components/schemas/ConnectionUsageLimit'
          type: array
        name:
          description: >-
            The name you gave the connection, unique among your connections of
            its option.
          minLength: 1
          type: string
        option:
          enum:
            - openrouter_api_key
          type: string
        profiles:
          description: The agent profiles that run on the connection.
          items:
            $ref: '#/components/schemas/ConnectionProfile'
          type: array
        reauth:
          anyOf:
            - $ref: '#/components/schemas/ConnectionReauth'
            - type: 'null'
      required:
        - option
        - id
        - name
        - reauth
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    ConnectionCreditsLimit:
      additionalProperties: false
      properties:
        reason:
          minLength: 1
          type: string
        scope:
          enum:
            - credits
          type: string
        until:
          format: date-time
          type:
            - string
            - 'null'
      required:
        - scope
        - until
        - reason
      type: object
    ConnectionModelLimit:
      additionalProperties: false
      properties:
        model:
          minLength: 1
          type: string
        reason:
          minLength: 1
          type: string
        scope:
          enum:
            - model
          type: string
        until:
          format: date-time
          type:
            - string
            - 'null'
      required:
        - scope
        - until
        - reason
        - model
      type: object
    ConnectionSessionLimit:
      additionalProperties: false
      properties:
        reason:
          minLength: 1
          type: string
        scope:
          enum:
            - session
          type: string
        until:
          format: date-time
          type:
            - string
            - 'null'
      required:
        - scope
        - until
        - reason
      type: object
    ConnectionUsageLimit:
      additionalProperties: false
      properties:
        reason:
          minLength: 1
          type: string
        scope:
          enum:
            - usage
          type: string
        until:
          format: date-time
          type:
            - string
            - 'null'
      required:
        - scope
        - until
        - reason
      type: object
    ConnectionWeeklyLimit:
      additionalProperties: false
      properties:
        reason:
          minLength: 1
          type: string
        scope:
          enum:
            - weekly
          type: string
        until:
          format: date-time
          type:
            - string
            - 'null'
      required:
        - scope
        - until
        - reason
      type: object
    ConnectionProfile:
      additionalProperties: false
      properties:
        id:
          format: uuid
          type: string
        name:
          minLength: 1
          type: string
        org:
          description: The name of the organization the profile belongs to.
          minLength: 1
          type: string
      required:
        - id
        - name
        - org
      type: object
    ConnectionReauth:
      additionalProperties: false
      properties:
        reason:
          description: Why the stored credential failed, as the vendor said.
          minLength: 1
          type: string
      required:
        - reason
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.