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

# Chat Completions

> Perform a Chat Completion request.



## OpenAPI

````yaml post /v1/chat/completions
openapi: 3.1.0
info:
  title: Pulze.ai API
  version: 0.1.0
servers: []
security: []
paths:
  /v1/chat/completions:
    post:
      tags:
        - chat
      summary: Chat Completions
      description: Perform a Chat Completion request.
      operationId: chat_completions_v1_chat_completions_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequestPayload'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PulzeEngineResponseChatCompletion'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ChatCompletionRequestPayload:
      properties:
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
          description: >

            https://docs.pulze.ai/overview/models

            Specify the model you'd like Pulze to use. (optional). Can be the
            full model name, or a subset for multi-matching.


            Defaults to our dynamic routing, i.e. best model for this request.
          default: pulze
        max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Tokens
          description: The maximum number of tokens that the response can contain.
        temperature:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Temperature
          description: >-
            Optionally specify the temperature for this request only. Leave
            empty to allow Pulze to guess it for you.
          default: 1
        top_p:
          anyOf:
            - type: number
            - type: 'null'
          title: Top P
          description: >

            https://octo.ai/docs/text-gen-solution/rest-api#input-parameters

            A value between 0.0 and 1.0 that controls the probability of the
            model generating a particular token.
          default: 1
        tools:
          anyOf:
            - items:
                $ref: '#/components/schemas/ToolFunction-Input'
              type: array
            - type: 'null'
          title: Tools
        tool_choice:
          anyOf:
            - type: string
              enum:
                - none
                - auto
            - $ref: '#/components/schemas/ToolChoice'
          title: Tool Choice
          default: none
        'n':
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: 'N'
          description: |

            How many completions to generate for each prompt.
            @default 1
        stream:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Stream
          description: >

            Specify if you want the response to be streamed or to be returned as
            a standard HTTP request.

            Currently we only support streaming for OpenAI-compatible models.
          default: false
        logprobs:
          anyOf:
            - type: integer
              maximum: 5
              minimum: 0
            - type: 'null'
          title: Logprobs
          description: >

            COMING SOON

            https://platform.openai.com/docs/api-reference/completions/create#completions/create-logprobs

            Include the log probabilities on the logprobs most likely tokens, as
            well the chosen tokens.
        stop:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Stop
          description: >

            Stop responding when this sequence of characters is generated. Leave
            empty to allow the model to decide.
          default: ''
        presence_penalty:
          anyOf:
            - type: number
              maximum: 2
              minimum: -2
            - type: 'null'
          title: Presence Penalty
          description: >

            https://platform.openai.com/docs/api-reference/completions/create#completions/create-presence_penalty

            Increase the model's likelihood to talk about new topics
        frequency_penalty:
          anyOf:
            - type: number
              maximum: 2
              minimum: -2
            - type: 'null'
          title: Frequency Penalty
          description: >

            https://platform.openai.com/docs/api-reference/completions/create#completions/create-frequency_penalty

            Increase the model's likelihood to not repeat tokens/words
        best_of:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Best Of
          description: >-
            The number of responses to _generate_. Out of those, it will return
            the best `n`.
        logit_bias:
          anyOf:
            - type: object
            - type: 'null'
          title: Logit Bias
          description: >

            COMING SOON

            https://platform.openai.com/docs/api-reference/completions/create#completions/create-logit_bias

            Modify the likelihood of specified tokens appearing in the
            completion.


            See here for a detailed explanation on how to use:

            https://help.openai.com/en/articles/5247780-using-logit-bias-to-define-token-probability
        response_format:
          anyOf:
            - $ref: '#/components/schemas/RequestResponseFormat'
            - type: 'null'
          description: >

            https://platform.openai.com/docs/api-reference/chat/create#chat-create-response_format

            An object specifying the format that the model must output. Must be
            one of "text" or "json_object".

            Important: when using JSON mode, you must also instruct the model to
            produce JSON yourself via a system or user message. To help ensure
            you don't forget, the API will throw an error if the string "JSON"
            does not appear somewhere in the context.
        messages:
          items:
            $ref: '#/components/schemas/RoleContentChatChoice-Input'
          type: array
          minItems: 1
          title: Messages
          description: >-
            The conversation sent (with or without history) (for a
            /chat/completions request)
        plugins:
          items:
            type: string
          type: array
          title: Plugins
          description: The list of plugins to enable for the request
      type: object
      required:
        - messages
      title: ChatCompletionRequestPayload
    PulzeEngineResponseChatCompletion:
      properties:
        choices:
          items:
            $ref: '#/components/schemas/ResponseCompletionChatChoice'
          type: array
          title: Choices
        created:
          type: integer
          title: Created
          description: Creation timestamp -- in milliseconds (!)
          default: 0
        metadata:
          $ref: '#/components/schemas/PulzeEngineResponseMetadata'
          description: Metadata of the response
        id:
          type: string
          title: Id
          description: This ID gets generated by the database when we save the request
        usage:
          $ref: '#/components/schemas/PulzeEngineTokens'
          description: Tokens used
        model:
          type: string
          title: Model
          description: The fully qualified model name used by PulzeEngine
        object:
          type: string
          enum:
            - text_completion
            - chat.completion
          title: Object
          description: The type of response object
      additionalProperties: true
      type: object
      required:
        - choices
        - model
        - object
      title: PulzeEngineResponseChatCompletion
      description: The response returned to the user by the Chat Completions endpoint
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ToolFunction-Input:
      properties:
        type:
          type: string
          enum:
            - function
          const: function
          title: Type
          default: function
        function:
          $ref: '#/components/schemas/ToolFunctionDetail'
      type: object
      required:
        - function
      title: ToolFunction
    ToolChoice:
      properties:
        type:
          anyOf:
            - type: string
              enum:
                - function
                - json_object
            - type: 'null'
          title: Type
          description: >

            (Note: Not supported by all models yet) //

            `json_object`: If you instruct the model to return a JSON object,
            the model will respond in a valid JSON format. ||

            `function`: If you set this to function, you must also pass the
            `function` parameter with extra information. ||
        function:
          anyOf:
            - $ref: '#/components/schemas/ToolChoiceFunction'
            - type: 'null'
          description: >-
            The definition of the function you would like the LLM to guess the
            parameters for.
      type: object
      title: ToolChoice
    RequestResponseFormat:
      properties:
        type:
          type: string
          enum:
            - text
            - json_object
          title: Type
      type: object
      required:
        - type
      title: RequestResponseFormat
    RoleContentChatChoice-Input:
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
            - system
          title: Role
        content:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/RoleContentChatChoiceContent'
              type: array
            - type: 'null'
          title: Content
        tool_calls:
          anyOf:
            - items:
                $ref: '#/components/schemas/ToolCall'
              type: array
            - type: 'null'
          title: Tool Calls
          description: >-
            If `tool_choice` parameter was passed, and the model supports it,
            this will return a list of the different calls/functions used.
      type: object
      required:
        - role
        - content
      title: RoleContentChatChoice
    ResponseCompletionChatChoice:
      properties:
        index:
          type: integer
          title: Index
        finish_reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Finish Reason
          description: >-
            The reason the model stopped generating tokens. Possible values:
            "stop", "length", "content_filter", "function_call", "max_tokens",
            ... 
          default: stop
        message:
          $ref: '#/components/schemas/RoleContentChatChoice-Output'
      type: object
      required:
        - index
        - message
      title: ResponseCompletionChatChoice
    PulzeEngineResponseMetadata:
      properties:
        app_id:
          type: string
          title: App Id
          description: The ID of the app this request belongs to
        model:
          anyOf:
            - $ref: '#/components/schemas/ModelParts'
            - type: 'null'
          description: The model used in the request
        costs:
          $ref: '#/components/schemas/PulzeEngineTokens'
          description: Cost (in $) of the request
        cost_savings:
          $ref: '#/components/schemas/PulzeEngineTokens'
          description: Price difference -- compared with GPT-4
        generated_artifacts:
          $ref: '#/components/schemas/PulzeGeneratedArtifacts'
          description: Generated artifacts
        search_results:
          $ref: '#/components/schemas/PulzeSearchResults'
          description: Search results
        latency:
          anyOf:
            - type: number
            - type: 'null'
          title: Latency
          description: The time it took for the Provider to return a response
        labels:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Labels
          description: Custom labels (metadata) sent along in the request
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: If an error occurs, it will be stored here
        scores:
          anyOf:
            - $ref: '#/components/schemas/RankedScoringModels'
            - type: 'null'
          description: A ranking of the best models for a given request
        score:
          anyOf:
            - type: number
            - type: 'null'
          title: Score
          description: The score for the currently used LLM
          default: 0
        temperature:
          anyOf:
            - type: number
            - type: integer
            - type: 'null'
          title: Temperature
          description: Temperature used for the request
        max_tokens:
          anyOf:
            - type: integer
              minimum: -1
            - type: 'null'
          title: Max Tokens
          description: >-
            Maximum number of tokens that can be used in the
            request+response.Leave empty to make it automatic, and set to `-1`
            to use the maximum context size (model-dependent)
        status_code:
          anyOf:
            - type: integer
            - type: 'null'
          title: Status Code
          description: Status code of the response
        retries:
          type: integer
          title: Retries
          description: >-
            The number of retries needed to get the answer. `null` or `0` means
            no retries were required
          default: 0
        extra:
          anyOf:
            - type: object
            - type: 'null'
          title: Extra
          description: Extra data
        warning:
          anyOf:
            - type: string
            - type: 'null'
          title: Warning
          description: Show a warning -- deprecation messages, etc.
      type: object
      title: PulzeEngineResponseMetadata
    PulzeEngineTokens:
      properties:
        total_tokens:
          type: number
          title: Total Tokens
          default: 0
        prompt_tokens:
          type: number
          title: Prompt Tokens
          default: 0
        completion_tokens:
          type: number
          title: Completion Tokens
          default: 0
      type: object
      title: PulzeEngineTokens
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ToolFunctionDetail:
      properties:
        name:
          type: string
          title: Name
          description: A unique name for the function
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: >-
            A description of the function. Might help the LLM to figure out the
            structure and parameters
        parameters:
          $ref: '#/components/schemas/FunctionParameters'
          description: A JSON schema object with the parameter definitons
      type: object
      required:
        - name
        - parameters
      title: ToolFunctionDetail
    ToolChoiceFunction:
      properties:
        name:
          type: string
          title: Name
          description: The name of the function you'd like the code to call
      type: object
      required:
        - name
      title: ToolChoiceFunction
    RoleContentChatChoiceContent:
      properties:
        type:
          type: string
          enum:
            - text
            - image_url
          title: Type
        text:
          anyOf:
            - type: string
            - type: 'null'
          title: Text
        image_url:
          anyOf:
            - $ref: '#/components/schemas/RoleContentChatChoiceContentImageUrl'
            - type: 'null'
      type: object
      required:
        - type
      title: RoleContentChatChoiceContent
    ToolCall:
      properties:
        function:
          $ref: '#/components/schemas/FunctionCallArguments'
          description: >-
            A JSON schema with the values for each argument that the LLM
            predicted
        id:
          type: string
          title: Id
        type:
          type: string
          enum:
            - function
          const: function
          title: Type
          default: function
      type: object
      required:
        - function
        - id
      title: ToolCall
    RoleContentChatChoice-Output:
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
            - system
          title: Role
        content:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/RoleContentChatChoiceContent'
              type: array
            - type: 'null'
          title: Content
        tool_calls:
          anyOf:
            - items:
                $ref: '#/components/schemas/ToolCall'
              type: array
            - type: 'null'
          title: Tool Calls
          description: >-
            If `tool_choice` parameter was passed, and the model supports it,
            this will return a list of the different calls/functions used.
      type: object
      required:
        - role
        - content
      title: RoleContentChatChoice
    ModelParts:
      properties:
        model:
          type: string
          title: Model
          description: The name of the model. Can belong to many providers
        provider:
          anyOf:
            - type: string
            - type: 'null'
          title: Provider
          description: The provider for the model.
        owner:
          anyOf:
            - type: string
            - type: 'null'
          title: Owner
          description: >-
            The owner of the model. Sometimes, for a provider/model combination,
            many instances exist, trained on different data
        namespace:
          type: string
          title: Namespace
          description: The fully qualified (namespaced) model name
        at:
          anyOf:
            - type: string
            - type: 'null'
          title: At
          description: Extra model settings inferred from namespace
      type: object
      required:
        - model
        - namespace
      title: ModelParts
    PulzeGeneratedArtifacts:
      properties:
        items:
          items:
            type: object
          type: array
          title: Items
          description: Generated artifacts
      type: object
      title: PulzeGeneratedArtifacts
    PulzeSearchResults:
      properties:
        items:
          items:
            type: object
          type: array
          title: Items
          description: Search results
      type: object
      title: PulzeSearchResults
    RankedScoringModels:
      properties:
        best_models:
          items:
            additionalProperties:
              type: number
            type: object
          type: array
          title: Best Models
          default: []
        candidates:
          anyOf:
            - items:
                additionalProperties:
                  type: number
                type: object
              type: array
            - type: 'null'
          title: Candidates
      type: object
      title: RankedScoringModels
    FunctionParameters:
      properties:
        type:
          type: string
          title: Type
          description: Following JSON schema, this must be 'object'.
          default: object
        properties:
          additionalProperties:
            type: object
          type: object
          title: Properties
          description: JSON schema's properties
        required:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Required
          description: List of required parameters
      type: object
      required:
        - properties
        - required
      title: FunctionParameters
    RoleContentChatChoiceContentImageUrl:
      properties:
        url:
          type: string
          title: Url
      type: object
      required:
        - url
      title: RoleContentChatChoiceContentImageUrl
    FunctionCallArguments:
      properties:
        arguments:
          type: string
          title: Arguments
          description: A stringified JSON that represents the arguments for the function
        name:
          type: string
          title: Name
          description: The name of the function to which the arguments correspond
      type: object
      required:
        - arguments
        - name
      title: FunctionCallArguments
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````