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

# Invoke LLM

> This endpoint allows you to invoke a language model using specific parameters, such as the expert and model IDs, input data, and additional configuration options.

<Note>
  Ensure that you replace `YOUR_API_KEY_HERE` with the actual API key generated
  from your profile in the B-Bot hub.
</Note>

<Note>
  The `temperature` parameter is optional. If not provided, a default value will
  be used.
</Note>

<Note>
  The `max_tokens` parameter is optional. If not provided, a default value will
  be used.
</Note>


## OpenAPI

````yaml POST /api/v1/invoke_llm
openapi: 3.0.1
info:
  title: B-Bot Hub Api Reference
  description: Our Api to manage content and Inference with B-Bot Hub
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.b-bot.space
security:
  - apiKey: []
paths:
  /api/v1/invoke_llm:
    post:
      description: >-
        This endpoint allows you to invoke a language model using specific
        parameters, such as the expert and model IDs, input data, and additional
        configuration options.
      requestBody:
        description: >-
          This endpoint allows you to invoke a language model using specific
          parameters, such as the expert and model IDs, input data, and
          additional configuration options.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvokeLanguageModel'
        required: true
      responses:
        '200':
          description: Successful response with generated content
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LLMResponse200'
        '400':
          description: Bad request due to invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LLMErrorResponse400'
        '401':
          description: The provided API key was invalid or missing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LLMErrorResponse401'
        '500':
          description: An error occurred on the server side.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LLMErrorResponse500'
components:
  schemas:
    InvokeLanguageModel:
      type: object
      properties:
        expert_id:
          type: integer
          example: 37
          description: The ID of the expert you want to invoke.
        model_id:
          type: integer
          example: 6
          description: The ID of the language model to be used.
        input_data:
          type: array
          items:
            type: object
            properties:
              role:
                type: string
                example: user
                description: The role of the message sender, typically 'user' or 'system'.
              content:
                type: string
                example: Hello!
                description: The content of the message.
          description: >-
            A list of message objects containing the role and content of the
            input data.
        temperature:
          type: number
          format: float
          example: 1
          description: >-
            The sampling temperature, which controls the randomness of the
            model's outputs.
        max_tokens:
          type: integer
          example: 250
          description: >-
            The maximum number of tokens (words or word pieces) to generate in
            the response.
      required:
        - expert_id
        - model_id
        - input_data
    LLMResponse200:
      type: object
      properties:
        response:
          type: object
          properties:
            id:
              type: string
              example: chatcmpl-9kCotn4TY5OcxYc8qFlulso5v8BpC
              description: The unique identifier for the chat completion.
            choices:
              type: array
              items:
                type: object
                properties:
                  finish_reason:
                    type: string
                    example: stop
                    description: The reason the completion ended.
                  index:
                    type: integer
                    example: 0
                    description: The index of the response choice.
                  logprobs:
                    type: object
                    example: null
                    description: The log probabilities (if any).
                  message:
                    type: object
                    properties:
                      content:
                        type: string
                        example: >-
                          Hello! How can I assist you today in the realm of
                          marketing psychology for your business?
                        description: The content of the message.
                      role:
                        type: string
                        example: assistant
                        description: The role of the message sender.
                      function_call:
                        type: object
                        example: null
                        description: Any function calls made by the assistant.
                      tool_calls:
                        type: object
                        example: null
                        description: Any tool calls made by the assistant.
            created:
              type: integer
              example: 1720799395
              description: The timestamp when the response was created.
            model:
              type: string
              example: gpt-3.5-turbo-0125
              description: The model used for the completion.
            object:
              type: string
              example: chat.completion
              description: The type of response object.
            system_fingerprint:
              type: object
              example: null
              description: The system fingerprint (if any).
            usage:
              type: object
              properties:
                completion_tokens:
                  type: integer
                  example: 18
                  description: The number of tokens generated in the completion.
                prompt_tokens:
                  type: integer
                  example: 40
                  description: The number of tokens in the prompt.
                total_tokens:
                  type: integer
                  example: 58
                  description: The total number of tokens used.
    LLMErrorResponse400:
      type: object
      properties:
        code:
          type: integer
          example: 400
        message:
          type: string
          example: Invalid parameters provided.
        details:
          type: string
          example: The 'input_data' field is required.
      required:
        - code
        - message
    LLMErrorResponse401:
      type: object
      properties:
        code:
          type: integer
          example: 401
        message:
          type: string
          example: Unauthorized access. API key is missing or invalid.
      required:
        - code
        - message
    LLMErrorResponse500:
      type: object
      properties:
        code:
          type: integer
          example: 500
        message:
          type: string
          example: An unexpected error occurred on the server.
        details:
          type: string
          example: Please try again later.
      required:
        - code
        - message
  securitySchemes:
    apiKey:
      type: apiKey
      name: bbot-api-key
      in: header
      description: API key for authentication

````