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

# Create Application Interaction



## OpenAPI

````yaml https://app.stainlessapi.com/api/spec/documented/sgp/openapi.yml post /v4/interactions/
openapi: 3.1.0
info:
  title: EGP API V4
  description: >-
    This is the parent API for all EGP APIs. If you are looking for the EGP API,
    please go to https://api.egp.scale.com/docs.
  contact:
    name: Scale Generative AI Platform
    url: https://scale.com/genai-platform
  version: 0.1.0
servers:
  - url: https://api.egp.scale.com
security: []
tags:
  - name: Models
    description: Model API.
paths:
  /v4/interactions/:
    post:
      tags:
        - Interactions
      summary: Create Application Interaction
      operationId: POST-V4-/
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InteractionRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InteractionEntity'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from datetime import datetime
            from scale_gp import SGPClient

            client = SGPClient(
                api_key=os.environ.get("SGP_API_KEY"),  # This is the default and can be omitted
            )
            interaction = client.interactions.create(
                application_variant_id="application_variant_id",
                input={
                    "query": "query"
                },
                output={
                    "response": "response"
                },
                start_timestamp=datetime.fromisoformat("2019-12-27T18:11:19.117"),
            )
            print(interaction.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/stainless-sdks/sgp-go\"\n\t\"github.com/stainless-sdks/sgp-go/option\"\n)\n\nfunc main() {\n\tclient := sgp.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tinteraction, err := client.Interactions.New(context.TODO(), sgp.InteractionNewParams{\n\t\tApplicationVariantID: sgp.F(\"application_variant_id\"),\n\t\tInput: sgp.F(sgp.InteractionNewParamsInput{\n\t\t\tQuery: sgp.F(\"query\"),\n\t\t}),\n\t\tOutput: sgp.F(sgp.InteractionNewParamsOutput{\n\t\t\tResponse: sgp.F(\"response\"),\n\t\t}),\n\t\tStartTimestamp: sgp.F(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", interaction.ID)\n}\n"
components:
  schemas:
    InteractionRequest:
      properties:
        application_variant_id:
          type: string
          title: Application Variant Id
          description: >-
            Identifier for the application variant that performed this
            interaction.
        thread_id:
          title: Thread Id
          description: >-
            Optional UUID identifying the conversation thread associated with
            the interaction.The interaction will be associated with the thread
            if the id represents an existing thread.If the thread with the
            specified id is not found, a new thread will be created.
          type: string
        input:
          $ref: '#/components/schemas/InteractionInput'
          description: The input data for the interaction.
        output:
          $ref: '#/components/schemas/InteractionOutput'
          description: The output data from the interaction.
        start_timestamp:
          type: string
          format: date-time
          title: Start Timestamp
          description: Timestamp marking the start of the interaction.
        duration_ms:
          title: Duration Ms
          description: Duration of the interaction in milliseconds.
          default: 0
          type: integer
        operation_status:
          $ref: '#/components/schemas/OperationStatus'
          description: The outcome status of the interaction.
          default: SUCCESS
        operation_metadata:
          additionalProperties: true
          type: object
          title: Operation Metadata
          description: >-
            Optional metadata related to the operation, including custom or
            predefined keys.
          default: {}
        trace_spans:
          title: Trace Spans
          description: >-
            List of trace spans associated with the interaction.These spans
            provide insight into the individual steps taken by nodes involved in
            generating the output.
          items:
            $ref: '#/components/schemas/TraceSpanRequest'
          type: array
      type: object
      required:
        - application_variant_id
        - input
        - output
        - start_timestamp
      title: InteractionRequest
      description: >-
        Represents an interaction performed with an application, including
        input, output, and associated metadata.
    InteractionEntity:
      properties:
        application_variant_id:
          type: string
          title: Application Variant Id
          description: >-
            Identifier for the application variant that performed this
            interaction.
        thread_id:
          title: Thread Id
          description: >-
            Optional UUID identifying the conversation thread associated with
            the interaction.The interaction will be associated with the thread
            if the id represents an existing thread.If the thread with the
            specified id is not found, a new thread will be created.
          type: string
        input:
          $ref: '#/components/schemas/InteractionInput'
          description: The input data for the interaction.
        output:
          $ref: '#/components/schemas/InteractionOutput'
          description: The output data from the interaction.
        start_timestamp:
          type: string
          format: date-time
          title: Start Timestamp
          description: Timestamp marking the start of the interaction.
        duration_ms:
          title: Duration Ms
          description: Duration of the interaction in milliseconds.
          default: 0
          type: integer
        operation_status:
          $ref: '#/components/schemas/OperationStatus'
          description: The outcome status of the interaction.
          default: SUCCESS
        operation_metadata:
          additionalProperties: true
          type: object
          title: Operation Metadata
          description: >-
            Optional metadata related to the operation, including custom or
            predefined keys.
          default: {}
        trace_spans:
          title: Trace Spans
          description: List of trace span entities associated with the interaction.
          items:
            $ref: '#/components/schemas/TraceSpanEntity'
          type: array
        id:
          type: string
          title: Id
          description: Unique identifier for the interaction.
      type: object
      required:
        - application_variant_id
        - input
        - output
        - start_timestamp
        - id
      title: InteractionEntity
      description: Model representing an interaction entity.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    InteractionInput:
      properties:
        query:
          type: string
          title: Query
          description: The query or input text for the interaction.
      additionalProperties: true
      type: object
      required:
        - query
      title: InteractionInput
      description: Represents the input of an interaction.
    InteractionOutput:
      properties:
        response:
          type: string
          title: Response
          description: The response or output text of the interaction.
        context:
          title: Context
          description: Optional context information provided with the response.
          items:
            $ref: '#/components/schemas/InteractionOutputContextEntry'
          type: array
      additionalProperties: true
      type: object
      required:
        - response
      title: InteractionOutput
      description: Represents the output of an interaction.
    OperationStatus:
      type: string
      enum:
        - SUCCESS
        - ERROR
      title: OperationStatus
      description: Enum representing the status of an operation.
    TraceSpanRequest:
      properties:
        node_id:
          type: string
          title: Node Id
          description: Identifier for the node that emitted this trace span.
        operation_type:
          $ref: '#/components/schemas/OperationType'
          description: Type of the operation, e.g., RERANKING.
        operation_status:
          $ref: '#/components/schemas/OperationStatus'
          description: The outcome of the operation performed by this node.
          default: SUCCESS
        start_timestamp:
          type: string
          format: date-time
          title: Start Timestamp
          description: The start time of the step.
        end_timestamp:
          title: End Timestamp
          description: The end time of the step.
          type: string
          format: date-time
        operation_input:
          additionalProperties: true
          type: object
          title: Operation Input
          description: The JSON representation of the input that this step received.
          default: {}
        operation_output:
          additionalProperties: true
          type: object
          title: Operation Output
          description: The JSON representation of the output that this step emitted.
          default: {}
        operation_metadata:
          additionalProperties: true
          type: object
          title: Operation Metadata
          description: >-
            The JSON representation of the metadata insights emitted during
            execution. This can differ based on different types of operations.
          default: {}
        duration_ms:
          type: integer
          title: Duration Ms
          description: The duration of the operation step in milliseconds.
          default: 0
        account_id:
          title: Account Id
          description: The ID of the account that owns this trace span.
          type: string
      type: object
      required:
        - node_id
        - operation_type
        - start_timestamp
      title: TraceSpanRequest
      description: >-
        Represents a trace span request, that contains the details of certain
        steps that took part in the interaction.
    TraceSpanEntity:
      properties:
        node_id:
          type: string
          title: Node Id
          description: Identifier for the node that emitted this trace span.
        operation_type:
          $ref: '#/components/schemas/OperationType'
          description: Type of the operation, e.g., RERANKING.
        operation_status:
          $ref: '#/components/schemas/OperationStatus'
          description: The outcome of the operation performed by this node.
          default: SUCCESS
        start_timestamp:
          type: string
          format: date-time
          title: Start Timestamp
          description: The start time of the step.
        end_timestamp:
          title: End Timestamp
          description: The end time of the step.
          type: string
          format: date-time
        operation_input:
          additionalProperties: true
          type: object
          title: Operation Input
          description: The JSON representation of the input that this step received.
          default: {}
        operation_output:
          additionalProperties: true
          type: object
          title: Operation Output
          description: The JSON representation of the output that this step emitted.
          default: {}
        operation_metadata:
          additionalProperties: true
          type: object
          title: Operation Metadata
          description: >-
            The JSON representation of the metadata insights emitted during
            execution. This can differ based on different types of operations.
          default: {}
        duration_ms:
          type: integer
          title: Duration Ms
          description: The duration of the operation step in milliseconds.
          default: 0
        account_id:
          title: Account Id
          description: The ID of the account that owns this trace span.
          type: string
        id:
          type: string
          title: Id
          description: Unique identifier for the trace span.
        application_interaction_id:
          type: string
          title: Application Interaction Id
          description: The ID of the application interaction this trace span belongs to.
      type: object
      required:
        - node_id
        - operation_type
        - start_timestamp
        - id
        - application_interaction_id
      title: TraceSpanEntity
      description: Represents a trace span entity, tied to an interaction.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
          additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    InteractionOutputContextEntry:
      properties:
        text:
          type: string
          title: Text
          description: The text of the context entry.
        score:
          title: Score
          description: The score of the context entry.
          type: number
      additionalProperties: true
      type: object
      required:
        - text
      title: InteractionOutputContextEntry
    OperationType:
      type: string
      enum:
        - COMPLETION
        - RERANKING
        - RETRIEVAL
        - CUSTOM
      title: OperationType
      description: Enum representing the type of operation performed.

````