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

# Connect a model provider

> Connect a model provider with one of your own keys.



## OpenAPI

````yaml /openapi.json post /v1/model-credentials
openapi: 3.1.0
info:
  title: Gobare Agent API
  version: v1
  description: >-
    Programmatic access to Gobare coding-agent sessions. Conceptually aligned
    with OpenAI's Agents API; deliberately not wire-compatible with it. See the
    divergence list in the product documentation.
servers:
  - url: https://api.{domain}
    variables:
      domain:
        default: gobare.dev
security: []
paths:
  /v1/model-credentials:
    post:
      summary: Connect a model provider
      description: Connect a model provider with one of your own keys.
      operationId: post_model_credentials
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            maxLength: 255
          description: >-
            Retrying with the same key replays the first answer instead of
            acting again.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ModelCredentialCreateRequest'
      responses:
        '201':
          description: Connect a model provider with one of your own keys.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModelCredential'
        '400':
          description: >-
            `invalid_request`. A field this endpoint does not read, a field of
            the wrong shape, a query parameter it does not take, or a body past
            the size ceiling. Refused rather than ignored: a setting you believe
            you made is one we really made.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: The access token is missing, unrecognised, expired or revoked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            The token is valid but may not perform this call. The message names
            the scope it wanted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            No such endpoint, or the public API is not enabled on this
            deployment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            The session's state does not allow this call, or an identical
            request is already in flight under the same Idempotency-Key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            `rate_limit_exceeded` — the token is past its allowance for this
            bucket; honour `Retry-After`. Or `queue_full` — too many messages
            are already waiting behind the current turn. Branch on `code`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: An unexpected error. Quote the request id.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - accessToken: []
components:
  schemas:
    ModelCredentialCreateRequest:
      type: object
      example:
        key: sk-ant-api03-…
        label: Anthropic
      required:
        - key
      properties:
        key:
          type: string
          description: >-
            The provider key. Verified against the provider before it is stored,
            and returned nowhere afterwards.
        provider:
          type: string
          description: >-
            Which vendor issued the key. Only needed when the prefix does not
            say: several vendors issue keys starting with `sk-`, and we ask
            rather than send your secret to vendors you never named.
        model:
          type: string
          description: Omit to accept the connector's default.
        base_url:
          type: string
          description: For `custom`, and for self-hosted or proxied endpoints.
        label:
          type: string
          description: A name for the Console's list. Defaults to the provider's.
        default:
          type: boolean
          description: >-
            Whether sessions naming no credential get this one. The first
            connection is always the default. Must be a boolean — a string is
            refused rather than read as false, because this decides whose bill
            every future turn lands on.
    ModelCredential:
      type: object
      required:
        - object
        - id
        - model
      properties:
        object:
          type: string
          const: model_credential
          description: >-
            Always `model_credential`. Names the shape, so a value can be
            identified without knowing which call returned it.
        id:
          type: string
          description: Pass as agent.model_credential_id.
        label:
          type: string
          description: Yours, from the Console. For recognising the connection.
        connector:
          type: string
          description: Which provider integration it uses.
        model:
          type: string
          description: agent.model must match this.
        is_default:
          type: boolean
          description: Whether a session that names no credential gets this one.
        last4:
          type: string
          description: >-
            The last four characters of the key. On create only; the key itself
            is never returned.
        verified:
          type: boolean
          description: Whether the provider accepted a probe before this was stored.
    Error:
      type: object
      required:
        - error
      description: Every refusal this API makes, in one shape.
      properties:
        error:
          description: Always present on a failure, and the only thing present.
          type: object
          required:
            - code
            - message
            - request_id
          properties:
            code:
              type: string
              enum:
                - invalid_request
                - authentication_error
                - permission_denied
                - not_found
                - method_not_allowed
                - conflict
                - queue_full
                - rate_limit_exceeded
                - project_limit_exceeded
                - context_length_exceeded
                - provider_error
                - provider_unauthorized
                - sandbox_error
                - sandbox_unavailable
                - directory_unavailable
                - workspace_recovery_failed
                - bridge_incompatible
                - internal_error
            message:
              type: string
            request_id:
              type: string
              description: >-
                Also on the x-request-id header. Quote it when reporting a
                problem.
  securitySchemes:
    accessToken:
      type: http
      scheme: bearer
      description: >-
        A `gbr_pat_` access token. Scopes are recorded on the token when it is
        minted.

````