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

# System One

> Send a state and questions about it to any Nimble model. The model field picks the model. Fact check models take the document as a string state and one noul question for each claim. Code search models take a query and a list of items in the state. The path /v1/nimble/systemone takes the same requests.



## OpenAPI

````yaml api-reference/openapi.yaml POST /v1/systemone
openapi: 3.1.0
info:
  title: Bespoke Labs API
  version: '1.0'
servers:
  - url: https://api.bespokelabs.ai
security:
  - bearerAuth: []
paths:
  /v1/systemone:
    post:
      summary: System One
      description: >-
        Send a state and questions about it to any Nimble model. The model field
        picks the model. Fact check models take the document as a string state
        and one noul question for each claim. Code search models take a query
        and a list of items in the state. The path /v1/nimble/systemone takes
        the same requests.
      operationId: systemOne
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SystemOneRequest'
            examples:
              questions:
                summary: Questions (nimble-latest)
                value:
                  model: nimble-latest
                  state: >-
                    The customer was charged twice and asks for a refund. The
                    service still works.
                  questions:
                    refund:
                      type: noul
                      instructions: Does the customer request a refund?
                    department:
                      type: choice
                      instructions: Which department should handle this request?
                      criteria:
                        billing: Charges, payments and refunds
                        technical: Software bugs and outages
                    urgency:
                      type: score
                      instructions: How urgent is this request?
                      criteria:
                        - Routine billing request; service works
                        - Some functionality unavailable
                        - Complete service outage
              factcheck:
                summary: Fact check (nimble-factcheck)
                value:
                  model: nimble-factcheck
                  state: >-
                    The board moved the vote to Tuesday because the CFO was
                    travelling.
                  questions:
                    moved:
                      type: noul
                      instructions: The vote was moved to Tuesday.
                    ceo:
                      type: noul
                      instructions: The CEO was travelling.
              codegrep:
                summary: Code search (nimble-codegrep)
                value:
                  model: nimble-codegrep
                  state:
                    query: Uploads retry forever after a 413 response.
                    items:
                      - id: n0
                        path: src/upload/retry.py
                        kind: file
                        filePreview:
                          text: |-
                            def backoff(attempt):
                                while True:
                                    retry()
                      - id: n1
                        path: src/upload
                        kind: directory
                        childPreview:
                          entries:
                            - name: retry.py
                              kind: file
                  questions:
                    q0:
                      type: noul
                      instructions: >-
                        Does the file src/upload/retry.py contain code needed
                        for this query?
                    q1:
                      type: noul
                      instructions: >-
                        Is the directory src/upload worth exploring for this
                        query?
      responses:
        '200':
          description: The answers, keyed by question ID.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            x-typesafe-request-id:
              $ref: '#/components/headers/TypesafeRequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SystemOneResponse'
              examples:
                questions:
                  summary: Questions (nimble-latest)
                  value:
                    model: nimble-latest
                    answers:
                      refund:
                        type: noul
                        noul: 0.998
                      department:
                        type: choice
                        choice: billing
                        probabilities:
                          billing: 1
                          technical: 0
                        confidence: 1
                      urgency:
                        type: score
                        score: 0
                        legend:
                          '0': Routine billing request; service works
                          '1': Some functionality unavailable
                          '2': Complete service outage
                        probabilities:
                          '0': 1
                          '1': 0
                          '2': 0
                        confidence: 1
                    usage:
                      input_tokens: 338
                      output_tokens: 4
                factcheck:
                  summary: Fact check (nimble-factcheck)
                  value:
                    model: nimble-factcheck
                    answers:
                      moved:
                        type: noul
                        noul: 0.99
                      ceo:
                        type: noul
                        noul: 0.002
                    usage:
                      input_tokens: 25
                      output_tokens: 0
                    request_id: 6b57f82e-6905-48a1-bc44-fe0af138d8c5
                codegrep:
                  summary: Code search (nimble-codegrep)
                  value:
                    model: nimble-codegrep
                    effort: medium
                    answers:
                      q0:
                        type: noul
                        noul: 0.99
                      q1:
                        type: noul
                        noul: 0.99
                    details:
                      q0:
                        raw: 0.85
                        overflow: false
                        escalated: false
                        scores:
                          nimble-codegrep-4b: 0.85
                      q1:
                        raw: 0.82
                        overflow: false
                        escalated: false
                        scores:
                          nimble-codegrep-4b: 0.82
                    usage:
                      input_tokens: 472
                      output_tokens: 2
                    request_id: 0789d4c7-399f-4e70-9721-9f21bab043bc
                    escalation_skipped: false
        '401':
          description: The API key is missing or not valid.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            x-typesafe-request-id:
              $ref: '#/components/headers/TypesafeRequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: Your organization does not have enough credit for the request.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            x-typesafe-request-id:
              $ref: '#/components/headers/TypesafeRequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: The request body is larger than 1 MiB.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            x-typesafe-request-id:
              $ref: '#/components/headers/TypesafeRequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            The request is not valid, or it is above a limit. The detail field
            says why.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            x-typesafe-request-id:
              $ref: '#/components/headers/TypesafeRequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            Your organization already has 8 requests running. Retry after the
            number of seconds in the Retry-After header.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            x-typesafe-request-id:
              $ref: '#/components/headers/TypesafeRequestId'
            Retry-After:
              $ref: '#/components/headers/RetryAfter'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: A model returned an error. Retry with backoff.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            x-typesafe-request-id:
              $ref: '#/components/headers/TypesafeRequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            A model is starting, or Nimble is not available for a moment. Retry
            after the number of seconds in the Retry-After header. You are not
            charged.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            x-typesafe-request-id:
              $ref: '#/components/headers/TypesafeRequestId'
            Retry-After:
              $ref: '#/components/headers/RetryAfter'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '504':
          description: The request took too long.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            x-typesafe-request-id:
              $ref: '#/components/headers/TypesafeRequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '529':
          description: A general model is busy. Retry after about one second, with backoff.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            x-typesafe-request-id:
              $ref: '#/components/headers/TypesafeRequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    SystemOneRequest:
      description: >-
        The model field picks the model, and the model decides what the state
        and the questions must look like.
      oneOf:
        - $ref: '#/components/schemas/GeneralRequest'
        - $ref: '#/components/schemas/FactcheckRequest'
        - $ref: '#/components/schemas/CodegrepRequest'
    SystemOneResponse:
      type: object
      required:
        - model
        - answers
        - usage
      properties:
        model:
          type: string
          description: The model name from the request.
        answers:
          type: object
          description: Question IDs mapped to answers.
          additionalProperties:
            $ref: '#/components/schemas/Answer'
        usage:
          $ref: '#/components/schemas/Usage'
        request_id:
          type: string
          description: >-
            Fact check and code search only. The same ID as the x-request-id
            header.
        effort:
          type: string
          enum:
            - low
            - medium
            - high
          description: >-
            Code search only. low for nimble-codegrep-lite, medium for
            nimble-codegrep, and high for nimble-codegrep-max.
        details:
          type: object
          description: >-
            Code search only. Question IDs mapped to details about how each item
            was scored.
          additionalProperties:
            $ref: '#/components/schemas/CodegrepDetail'
        escalation_skipped:
          type: boolean
          description: Code search only. Always false in a 200 response.
    Error:
      type: object
      required:
        - detail
        - request_id
      properties:
        detail:
          description: Why the request failed.
        request_id:
          type: string
          description: The ID of this request, the same as the x-request-id header.
    GeneralRequest:
      type: object
      title: General models
      description: >-
        Typed questions about text or JSON, for nimble-latest, nimble-v3 or the
        previous model.
      required:
        - state
        - questions
      properties:
        model:
          type: string
          enum:
            - nimble-latest
            - nimble-v3
            - bespokelabs/Bespoke-Nimble-9B-v3
            - bespokelabs/Bespoke-Nimble-9B
          default: nimble-latest
          description: >-
            nimble-latest is the newest general model, which is nimble-v3 now.
            nimble-v3 and bespokelabs/Bespoke-Nimble-9B-v3 stay on this model,
            and bespokelabs/Bespoke-Nimble-9B is the previous model. The
            response repeats this name.
        state:
          description: >-
            The text or JSON to ask about. Nimble reads a JSON state as JSON
            text.
          oneOf:
            - type: string
            - type: object
            - type: array
        questions:
          type: object
          description: Your question IDs mapped to questions. The answers use the same IDs.
          minProperties: 1
          maxProperties: 64
          additionalProperties:
            $ref: '#/components/schemas/GeneralQuestion'
    FactcheckRequest:
      type: object
      title: Fact check
      description: Claims to check against a document.
      required:
        - model
        - state
        - questions
      properties:
        model:
          type: string
          enum:
            - nimble-factcheck-lite
            - nimble-factcheck
            - nimble-factcheck-max
          description: The fact check model. The response repeats this name.
        state:
          type: string
          maxLength: 400000
          description: The document.
        questions:
          type: object
          description: Your claim IDs mapped to claims. The answers use the same IDs.
          minProperties: 1
          maxProperties: 64
          additionalProperties:
            $ref: '#/components/schemas/ClaimQuestion'
        split_claims:
          type: boolean
          default: true
          description: >-
            Score each sentence of a claim on its own and keep the lowest score.
            Set it to false to score each claim whole.
    CodegrepRequest:
      type: object
      title: Code search
      description: A query and the files and folders to score for it.
      required:
        - model
        - state
        - questions
      properties:
        model:
          type: string
          enum:
            - nimble-codegrep-lite
            - nimble-codegrep
            - nimble-codegrep-max
          description: The code search model. The response repeats this name.
        state:
          description: >-
            The query and the items to score, in at most 2,000,000 characters.
            Question q<i> is about item n<i>. A string state is accepted too,
            and Nimble uses it whole for every question, but the models were not
            trained on that.
          oneOf:
            - type: object
              required:
                - query
                - items
              properties:
                query:
                  type: string
                  description: What the coding agent is looking for.
                items:
                  type: array
                  description: The files and folders to score.
                  items:
                    type: object
                    required:
                      - id
                      - path
                      - kind
                    properties:
                      id:
                        type: string
                        description: n0, n1, and so on. Question q<i> is about item n<i>.
                      path:
                        type: string
                      kind:
                        type: string
                        enum:
                          - file
                          - directory
                      filePreview:
                        type: object
                        description: Part of a file's text.
                      childPreview:
                        type: object
                        description: The entries of a folder.
            - type: string
        questions:
          type: object
          description: Your question IDs mapped to questions. The answers use the same IDs.
          minProperties: 1
          maxProperties: 128
          additionalProperties:
            $ref: '#/components/schemas/CodegrepQuestion'
    Answer:
      oneOf:
        - $ref: '#/components/schemas/NoulAnswer'
        - $ref: '#/components/schemas/ChoiceAnswer'
        - $ref: '#/components/schemas/ScoreAnswer'
      discriminator:
        propertyName: type
        mapping:
          noul:
            $ref: '#/components/schemas/NoulAnswer'
          choice:
            $ref: '#/components/schemas/ChoiceAnswer'
          score:
            $ref: '#/components/schemas/ScoreAnswer'
    Usage:
      type: object
      required:
        - input_tokens
        - output_tokens
      properties:
        input_tokens:
          type: integer
          description: The input tokens that you pay for.
        output_tokens:
          type: integer
    CodegrepDetail:
      type: object
      properties:
        raw:
          type: number
          description: The model's own probability before Nimble adjusts it.
        overflow:
          type: boolean
          description: >-
            True when the item's prompt was longer than 8,192 tokens. The answer
            is then 1.0, and the item is not charged.
        escalated:
          type: boolean
          description: Whether a larger model scored the item.
        scores:
          type: object
          description: Each model's score for the item.
          additionalProperties:
            type: number
    GeneralQuestion:
      oneOf:
        - $ref: '#/components/schemas/NoulQuestion'
        - $ref: '#/components/schemas/ChoiceQuestion'
        - $ref: '#/components/schemas/ScoreQuestion'
      discriminator:
        propertyName: type
        mapping:
          noul:
            $ref: '#/components/schemas/NoulQuestion'
          choice:
            $ref: '#/components/schemas/ChoiceQuestion'
          score:
            $ref: '#/components/schemas/ScoreQuestion'
    ClaimQuestion:
      type: object
      title: Claim
      description: >-
        One claim to check, as a noul question. Fact check refuses criteria and
        other fields.
      required:
        - type
        - instructions
      additionalProperties: false
      properties:
        type:
          type: string
          const: noul
        instructions:
          type: string
          minLength: 1
          maxLength: 4000
          description: The claim.
    CodegrepQuestion:
      oneOf:
        - $ref: '#/components/schemas/NoulQuestion'
        - $ref: '#/components/schemas/BooleanQuestion'
      discriminator:
        propertyName: type
        mapping:
          noul:
            $ref: '#/components/schemas/NoulQuestion'
          boolean:
            $ref: '#/components/schemas/BooleanQuestion'
    NoulAnswer:
      type: object
      title: Noul answer
      required:
        - type
        - noul
      properties:
        type:
          type: string
          const: noul
        noul:
          type: number
          minimum: 0
          maximum: 1
          description: >-
            The probability that the statement is true. For fact check, the
            probability that the document supports every part of the claim. For
            code search, the probability that the agent needs the item.
    ChoiceAnswer:
      type: object
      title: Choice answer
      required:
        - type
        - choice
        - probabilities
        - confidence
      properties:
        type:
          type: string
          const: choice
        choice:
          type: string
          description: The option with the highest probability.
        probabilities:
          type: object
          description: Every option's probability. They add up to 1.
          additionalProperties:
            type: number
        confidence:
          type: number
          description: >-
            1 when one option has all the probability, 0 when every option is
            equally likely. It is not the chance that the answer is right.
    ScoreAnswer:
      type: object
      title: Score answer
      required:
        - type
        - score
        - legend
        - probabilities
        - confidence
      properties:
        type:
          type: string
          const: score
        score:
          type: number
          description: The expected level, counting from 0. It can fall between two levels.
        legend:
          type: object
          description: Level numbers mapped to their text.
          additionalProperties:
            type: string
        probabilities:
          type: object
          description: Every level's probability, keyed by level number. They add up to 1.
          additionalProperties:
            type: number
        confidence:
          type: number
          description: >-
            1 when one level has all the probability, 0 when every level is
            equally likely.
    NoulQuestion:
      type: object
      title: Noul
      description: Asks whether a statement is true.
      required:
        - type
      properties:
        type:
          type: string
          const: noul
        instructions:
          type: string
          description: The statement or question.
        criteria:
          type: object
          description: What true and false mean. Optional.
          properties:
            'true':
              type: string
            'false':
              type: string
    ChoiceQuestion:
      type: object
      title: Choice
      description: Asks which option fits best. Only for the general models.
      required:
        - type
        - criteria
      properties:
        type:
          type: string
          const: choice
        instructions:
          type: string
          description: The question.
        criteria:
          type: object
          description: >-
            Option keys mapped to descriptions. If a description is null, Nimble
            reads the key instead.
          minProperties: 2
          maxProperties: 255
          additionalProperties:
            type:
              - string
              - 'null'
    ScoreQuestion:
      type: object
      title: Score
      description: Asks where the state falls on a scale. Only for the general models.
      required:
        - type
        - criteria
      properties:
        type:
          type: string
          const: score
        instructions:
          type: string
          description: The question.
        criteria:
          type: array
          description: The levels, from lowest to highest.
          minItems: 2
          maxItems: 255
          items:
            type: string
    BooleanQuestion:
      type: object
      title: Boolean
      description: >-
        Only for code search. Nimble answers it the same way as a noul question,
        with a noul answer.
      required:
        - type
      properties:
        type:
          type: string
          const: boolean
        instructions:
          type: string
          description: The question.
  headers:
    RequestId:
      description: >-
        The ID of this request. Send it to Bespoke Labs when you report a
        problem.
      schema:
        type: string
    TypesafeRequestId:
      description: The same ID as x-request-id. TypeSafe's SDK reads this header.
      schema:
        type: string
    RetryAfter:
      description: The number of seconds to wait before you retry.
      schema:
        type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Your Bespoke Labs API key.

````