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

# Model Select

> Given an array of messages and the selection of LLMs you want to route between, `/model-select` will return a label for which LLM you should call.

Example usage:

```bash theme={null}
curl -X POST https://api.ironlabs.ai/api/v1/model-select \
        -H "Authorization: Bearer <IAI_API_Key>" \
        -H "Content-Type: application/json" \
        -d '{
  "messages": [
        {"role": "system", "content": "You are a world class software developer."},
        {"role": "assistant", "content": "How can I help you today?"},
        {"role": "user", "content": "Write a merge sort in Python."}
  ],
  "llm_providers": [
    {
      "provider": "openai",
      "model": "gpt-4-1106-preview"
    },
    {
      "provider": "anthropic",
      "model": "claude-3-opus-20240229"
    }
  ],
}'
```


## OpenAPI

````yaml POST /model-select
openapi: 3.0.1
info:
  title: Ironlabs AI API Documentation
  description: API documentation for  IronlabsAI's public endpoints.
  version: 0.0.1
servers:
  - url: https://app.ironlabs.ai/api/v1/
    description: Ironlabs API Server
security:
  - bearerAuth: []
paths:
  /model-select:
    post:
      summary: Model Selection
      description: >-
        Given an array of messages and the selection of LLMs you want to route
        between, `/model-select` will return a label for which LLM you should
        call.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ModelSelectRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModelSelectResponse'
        '400':
          description: Bad Request
        '404':
          description: Not Found
        '500':
          description: Internal Server Error
components:
  schemas:
    ModelSelectRequest:
      type: object
      required:
        - messages
        - llm_providers
      properties:
        messages:
          type: array
          description: The messages array in OpenAI format.
          items:
            $ref: '#/components/schemas/Message'
        llm_providers:
          type: array
          description: >-
            A list of LLM providers you want to route between. You can
            optionally define their custom attributes, such as price and
            latency.
          items:
            $ref: '#/components/schemas/LLMProvider'
        tools:
          type: array
          description: >-
            A list of tools the model may call. Currently, only functions are
            supported as a tool. Use this to provide a list of functions the
            model may generate JSON inputs for. A max of 128 functions are
            supported.
          items:
            $ref: '#/components/schemas/Tool'
        max_model_depth:
          type: integer
          format: int32
          description: The maximum depth considered in the ranked LLM providers list.
        tradeoff:
          type: string
          description: Additional routing tradeoffs. Valid values are "cost" and "latency".
        preference_id:
          type: string
          description: >-
            The preference ID created on the Not Diamond dashboard. Setting this
            value will change the ranking algorithm based on the preferences
            set.
        hash_content:
          type: boolean
          description: Whether to hash the content of messages.
          default: false
        previous_session:
          type: string
          description: >-
            The session ID from a previous API call. This allows you to link
            recommendations such that the recommendation engine knows which
            requests belong in the same group.
    ModelSelectResponse:
      type: object
      required:
        - llm_label
      properties:
        llm_label:
          type: string
          description: Label of the LLM you should call.
    Message:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          description: The role of the message sender.
          enum:
            - system
            - user
            - assistant
        content:
          type: string
          description: The content of the message.
    LLMProvider:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Name of the LLM provider.
        price:
          type: number
          format: float
          description: Price of the LLM provider.
        latency:
          type: number
          format: float
          description: Latency of the LLM provider.
        attributes:
          type: object
          description: Other custom attributes.
          additionalProperties: true
    Tool:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Name of the tool.
        description:
          type: string
          description: Description of the tool.
        parameters:
          type: object
          description: Parameters the tool accepts.
          additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````