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

# Stream Completion

> Get a completion response using either one of your organizationâ€™s deployed prompts, or by providing completion details including prompt and inputs in the request.

This endpoint acts as a LLM gateway/proxy endpoint to generate completions from different LLMs.



## OpenAPI

````yaml post /api/parea/v1/completion/stream
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security: []
paths:
  /api/parea/v1/completion/stream:
    post:
      summary: Stream Completion
      description: >-
        Get a completion response using either one of your organizationâ€™s
        deployed prompts, or by providing completion details including prompt
        and inputs in the request.


        This endpoint acts as a LLM gateway/proxy endpoint to generate
        completions from different LLMs.
      operationId: stream_completion_api_parea_v1_completion_stream_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompletionsSchema'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
        - APIKeyHeader: []
        - APIKeyHeader: []
components:
  schemas:
    CompletionsSchema:
      properties:
        llm_inputs:
          anyOf:
            - type: object
            - type: 'null'
          title: Llm Inputs
          description: >-
            Key-value pairs as inputs to prompt template. Only needs to be
            provided if `deployment_id` is provided or
            `llm_configuration.messages` are templated.
        llm_configuration:
          allOf:
            - $ref: '#/components/schemas/LLMInputsSchema'
          description: LLM configuration parameters such as messages, functions, etc.
          default: {}
        project_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Project Name
          description: Project name which is used to associate the log with a project.
          default: default
        project_uuid:
          anyOf:
            - type: string
            - type: 'null'
          title: Project Uuid
          description: >-
            Project UUID which is used to associate the log with a project. Does
            not need to be provided if the `project_name` is provided.
        experiment_uuid:
          anyOf:
            - type: string
            - type: 'null'
          title: Experiment Uuid
          description: >-
            Experiment UUID which is used to associate the log with an
            experiment.
        parent_trace_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Trace Id
          description: >-
            UUID of the parent log. If given, will be used to associate the
            generation in a chain & create hierarchical nested logs.
        root_trace_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Root Trace Id
          description: >-
            UUID of the root log. If given, will be used to associate the
            generation in a chain & create hierarchical nested logs.
        end_user_identifier:
          anyOf:
            - type: string
            - type: 'null'
          title: End User Identifier
          description: >-
            Special field to track the end user which is interacting with your
            LLM app.
        deployment_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Deployment Id
          description: >-
            This is the ID for a specific deployed prompt. You can find your
            deployed prompts on the Deployments tab. If a deployment_id is
            provided, Parea will fetch all of the associated configuration
            including model name, model parameters, and any associated
            functions. Any information provided on the llm_configuration field
            will be used instead of the associated deployed prompts fields.
        eval_metric_ids:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Eval Metric Ids
          description: >-
            List of evaluation metric IDs deployed on Parea which should be used
            to evaluate the completion output.
        metadata:
          anyOf:
            - type: object
            - type: 'null'
          title: Metadata
          description: Key-value pairs to be associated with the log.
        tags:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Tags
          description: List of tags to be associated with the log.
        target:
          anyOf:
            - type: string
            - type: 'null'
          title: Target
          description: >-
            Optional ground truth output for the inputs. Will be used for
            evaluation and can be used when creating a test case from the log.
        trace_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Trace Id
          description: UUID of the generation log. If not given, will be auto-generated.
        trace_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Trace Name
          description: >-
            Name of the generation log. If not given, will be auto-generated in
            the format `llm-{provider}`.
        provider_api_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Provider Api Key
          description: >-
            Provider API key to generate response. If not given, API keys saved
            on the platform will be used
        cache:
          type: boolean
          title: Cache
          description: >-
            If true, the completion will be cached to avoid latency & cost for
            any subsequent completion using the same inputs.
          default: true
        log_omit_inputs:
          type: boolean
          title: Log Omit Inputs
          description: >-
            If true, the inputs, llm_configuration.messages,
            llm_configuration.functions, llm_configuration.model_params will not
            be logged.
          default: false
        log_omit_outputs:
          type: boolean
          title: Log Omit Outputs
          description: If true, the generated response will not be logged.
          default: false
        log_omit:
          type: boolean
          title: Log Omit
          description: >-
            Equivalent to setting both log_omit_inputs and log_omit_outputs to
            true.
          default: false
        log_sample_rate:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Log Sample Rate
          description: >-
            If specified, this log and its entire associated trace will logged
            with this probability. Must be between 0 and 1 (incl.). Defaults to
            1.0 (i.e., keeping all logs)
          default: 1
        inference_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Inference Id
          description: Deprecated field which is the same `trace_id`
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Deprecated field
        retry:
          type: boolean
          title: Retry
          description: Deprecated field
          default: false
        fallback_strategy:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Fallback Strategy
          description: Deprecated field
        stream:
          type: boolean
          title: Stream
          description: Deprecated field. Use /completion/stream instead.
          default: false
      type: object
      title: CompletionsSchema
      examples:
        - end_user_identifier: 2596@gmail.com
          inputs:
            city: New York
          llm_configuration:
            function_call: auto
            functions:
              - description: Get the current weather in a given location.
                name: get_current_weather
                parameters:
                  properties:
                    location:
                      description: The city and state, e.g. San Francisco, CA
                      type: string
                    unit:
                      enum:
                        - celsius
                        - fahrenheit
                      type: string
                  required:
                    - location
                  type: object
            messages:
              - content: What is the weather in New York
                role: user
            model: gpt-4o-mini
            model_params:
              max_length: 500
              model: gpt-4o-mini
              temp: 0
            provider: openai
          metadata:
            purpose: testing
            user_id: user_2Q9afRAKe6SZrc3U7
          tags:
            - weather
            - forecast
        - deployment_id: p-qZrnFesaeCpqcXJ_yL3wi
          llm_inputs:
            x: Golang
            'y': Fiber
          metadata:
            purpose: testing
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    LLMInputsSchema:
      properties:
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
          description: Model name
        provider:
          anyOf:
            - $ref: '#/components/schemas/ProviderName'
            - type: 'null'
          description: Provider name
        model_params:
          anyOf:
            - $ref: '#/components/schemas/ModelParamsSchema'
            - type: 'null'
          description: Model parameters
        messages:
          anyOf:
            - items:
                $ref: '#/components/schemas/MessageSchema'
              type: array
            - type: 'null'
          title: Messages
          description: List of messages
        history:
          anyOf:
            - items:
                $ref: '#/components/schemas/MessageSchema'
              type: array
            - type: 'null'
          title: History
          description: >-
            List of history messages which are prepended to messages. Useful for
            chatbot applications which rely on deployed prompts.
        functions:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Functions
          description: List of function schemas, following the OpenAI API format
        function_call:
          anyOf:
            - type: string
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Function Call
          description: Optionally, specify the fnction call, following OpenAI API behavior.
      type: object
      title: LLMInputsSchema
    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
    ProviderName:
      type: string
      enum:
        - openai
        - azure
        - anthropic
        - anyscale
        - vertexai
        - aws_bedrock
        - openrouter
        - mistral
        - litellm
        - groq
        - fireworks
        - cohere
      title: ProviderName
    ModelParamsSchema:
      properties:
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
          description: Model name
          default: ''
        temp:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Temp
          description: Temperature
          default: 1
        top_p:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Top P
          description: Top p
          default: 1
        frequency_penalty:
          anyOf:
            - type: number
              maximum: 2
              minimum: -2
            - type: 'null'
          title: Frequency Penalty
          description: Frequency penalty
          default: 0
        presence_penalty:
          anyOf:
            - type: number
              maximum: 2
              minimum: -2
            - type: 'null'
          title: Presence Penalty
          description: Presence penalty
          default: 0
        max_length:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Length
          description: Max length of the output
        response_format:
          anyOf:
            - type: object
            - type: 'null'
          title: Response Format
          description: Response format
        safe_prompt:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Safe Prompt
          description: Safe prompt. Only used for Mistral
      type: object
      title: ModelParamsSchema
    MessageSchema:
      properties:
        content:
          anyOf:
            - type: string
            - items: {}
              type: array
            - type: 'null'
          title: Content
          description: Message content
          default: ''
        role:
          allOf:
            - $ref: '#/components/schemas/Role'
          description: Message role
          default: user
      type: object
      title: MessageSchema
    Role:
      type: string
      enum:
        - user
        - assistant
        - system
        - user
        - assistant
        - function
        - tool
      title: Role
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-user-id

````