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

# Publish records

> Publish records to a data source (formerly known as "inference pipeline").

<Note>
  Use this endpoint to stream individual inference data points to Openlayer.
  If you want to upload many inferences in one go, please use the [batch upload method](https://github.com/openlayer-ai/openlayer-python/blob/main/examples/monitoring/upload_batch_data.py) instead.
</Note>


## OpenAPI

````yaml post /inference-pipelines/{inferencePipelineId}/data-stream
openapi: 3.0.3
info:
  contact:
    email: support@openlayer.com
    name: Openlayer
    url: https://openlayer.com/
  description: API for interacting with the Openlayer server.
  title: Openlayer API
  version: '1.0'
  x-logo:
    url: https://logo.clearbit.com/openlayer.com
servers:
  - url: https://api.openlayer.com/v1
    description: Our prod backend
security:
  - bearerAuth: []
paths:
  /inference-pipelines/{inferencePipelineId}/data-stream:
    post:
      tags:
        - Monitoring
      summary: Publish inference
      description: Publish an inference data point to an inference pipeline.
      operationId: streamData
      parameters:
        - $ref: '#/components/parameters/inferencePipelineId'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                rows:
                  type: array
                  description: A list of inference data points with inputs and outputs
                  example:
                    - user_query: what is the meaning of life?
                      output: '42'
                      tokens: 7
                      cost: 0.02
                      timestamp: 1620000000
                  nullable: false
                  items:
                    type: object
                    additionalProperties: true
                config:
                  oneOf:
                    - $ref: '#/components/schemas/LLMData'
                    - $ref: '#/components/schemas/TabularClassificationData'
                    - $ref: '#/components/schemas/TabularRegressionData'
                    - $ref: '#/components/schemas/TextClassificationData'
                  example:
                    prompt:
                      - role: user
                        content: '{{ user_query }}'
                    inputVariableNames:
                      - user_query
                    outputColumnName: output
                    timestampColumnName: timestamp
                    costColumnName: cost
                    numOfTokenColumnName: tokens
                  description: >-
                    Configuration for the data stream. Depends on your
                    **Openlayer project task type**.
              required:
                - rows
                - config
      responses:
        '200':
          description: Status OK.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
        '500':
          $ref: '#/components/responses/UnexpectedError'
      x-codeSamples:
        - lang: python
          source: |
            from openlayer import Openlayer

            client = Openlayer()

            response = client.inference_pipelines.data.stream(
                "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                config={
                    "input_variable_names": ["user_query"],
                    "output_column_name": "output",
                    "num_of_token_column_name": "tokens",
                    "cost_column_name": "cost",
                    "timestamp_column_name": "timestamp",
                },
                rows=[
                    {
                        "user_query": "What is the meaning of life?",
                        "output": "42",
                        "tokens": 7,
                        "cost": 0.02,
                        "timestamp": 1620000000,
                    }
                ],
            )
            print(response.success)
        - lang: typescript
          source: >
            import Openlayer from 'openlayer';


            const client = new Openlayer();


            const response = await
            client.inferencePipelines.data.stream('c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f',
            {
              config: {
                inputVariableNames: ['user_query'],
                outputColumnName: 'output',
                numOfTokenColumnName: 'tokens',
                costColumnName: 'cost',
                timestampColumnName: 'timestamp',
              },
              rows: [
                {
                  user_query: 'What is the meaning of life?',
                  output: '42',
                  tokens: 7,
                  cost: 0.02,
                  timestamp: 1610000000,
                },
              ],
            });


            console.log(response.success);
        - lang: go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openlayer-ai/openlayer-go\"\n)\n\nclient := openlayer.NewClient()\nresponse, err := client.InferencePipelines.Data.Stream(\n\tcontext.TODO(),\n\t\"c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f\",\n\topenlayer.InferencePipelineDataStreamParams{\n\t\tConfig: openlayer.F[openlayer.InferencePipelineDataStreamParamsConfigUnion](openlayer.InferencePipelineDataStreamParamsConfigLlmData{\n\t\t\tInputVariableNames:   openlayer.F([]string{\"user_query\"}),\n\t\t\tOutputColumnName:     openlayer.F(\"output\"),\n\t\t\tNumOfTokenColumnName: openlayer.F(\"tokens\"),\n\t\t\tCostColumnName:       openlayer.F(\"cost\"),\n\t\t\tTimestampColumnName:  openlayer.F(\"timestamp\"),\n\t\t}),\n\t\tRows: openlayer.F([]map[string]interface{}{{\n\t\t\t\"user_query\": \"What is the meaning of life?\",\n\t\t\t\"output\":     \"42\",\n\t\t\t\"tokens\":     7,\n\t\t\t\"cost\":       0.02,\n\t\t\t\"timestamp\":  1710000000,\n\t\t}}),\n\t},\n)\nif err != nil {\n\tpanic(err.Error())\n}\nfmt.Printf(\"%+v\\n\", response.Success)\n"
        - lang: java
          source: >
            import com.openlayer.api.client.OpenlayerClient;

            import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient;

            import com.openlayer.api.core.JsonValue;

            import
            com.openlayer.api.models.inferencepipelines.data.DataStreamParams;

            import
            com.openlayer.api.models.inferencepipelines.data.DataStreamResponse;


            OpenlayerClient client = OpenlayerOkHttpClient.fromEnv();


            DataStreamParams params = DataStreamParams.builder()
                .inferencePipelineId("c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f")
                .config(DataStreamParams.Config.LlmData.builder()
                    .addInputVariableName("user_query")
                    .outputColumnName("output")
                    .numOfTokenColumnName("tokens")
                    .costColumnName("cost")
                    .timestampColumnName("timestamp")
                    .build())
                .addRow(DataStreamParams.Row.builder()
                    .putAdditionalProperty("user_query", JsonValue.from("what is the meaning of life?"))
                    .putAdditionalProperty("output", JsonValue.from("42"))
                    .putAdditionalProperty("tokens", JsonValue.from(7))
                    .putAdditionalProperty("cost", JsonValue.from(0.02))
                    .putAdditionalProperty("timestamp", JsonValue.from(1610000000))
                    .build())
                .build();
            DataStreamResponse response =
            client.inferencePipelines().data().stream(params);
        - lang: ruby
          source: |
            require "openlayer"

            openlayer = Openlayer::Client.new(api_key: ENV["OPENLAYER_API_KEY"])

            response = openlayer.inference_pipelines.data.stream(
              "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
              config: {
                inputVariableNames: ["user_query"],
                outputColumnName: "output",
                numOfTokenColumnName: "tokens",
                costColumnName: "cost",
                timestampColumnName: "timestamp"
              },
              rows: [
                {
                  user_query: "what is the meaning of life?",
                  output: "42",
                  tokens: 7,
                  cost: 0.02,
                  timestamp: 1610000000
                }
              ]
            )

            puts(response.success)
        - lang: curl
          source: |
            curl --request POST \
              --url https://api.openlayer.com/v1/inference-pipelines/{inferencePipelineId}/data-stream \
              --header 'Authorization: Bearer <token>' \
              --header 'Content-Type: application/json' \
              --data '{
              "rows": [
                {
                  "user_query": "what is the meaning of life?",
                  "output": "42",
                  "tokens": 7,
                  "cost": 0.02,
                  "timestamp": 1620000000
                }
              ],
              "config": {
                "prompt": [
                  {
                    "role": "user",
                    "content": "{{ user_query }}"
                  }
                ],
                "inputVariableNames": [
                  "user_query"
                ],
                        "outputColumnName": "output",
                        "timestampColumnName": "timestamp",
                        "costColumnName": "cost",
                        "numOfTokenColumnName": "tokens"
              }
            }'
components:
  parameters:
    inferencePipelineId:
      name: inferencePipelineId
      in: path
      description: The inference pipeline id (a UUID).
      required: true
      schema:
        type: string
        format: uuid
  schemas:
    LLMData:
      title: LLM
      type: object
      properties:
        numOfTokenColumnName:
          type: string
          description: Name of the column with the total number of tokens.
          example: num_tokens
          nullable: true
        contextColumnName:
          type: string
          description: >-
            Name of the column with the context retrieved. Applies to RAG use
            cases. Providing the context enables RAG-specific metrics.
          example: context
        costColumnName:
          type: string
          description: Name of the column with the cost associated with each row.
          example: cost
        groundTruthColumnName:
          type: string
          description: Name of the column with the ground truths.
          example: ground_truth
        inferenceIdColumnName:
          type: string
          description: >-
            Name of the column with the inference ids. This is useful if you
            want to update rows at a later point in time. If not provided, a
            unique id is generated by Openlayer.
          example: id
        inputVariableNames:
          type: array
          description: >-
            Array of input variable names. Each input variable should be a
            dataset column.
          example:
            - user_query
          items:
            type: string
        latencyColumnName:
          type: string
          description: Name of the column with the latencies.
          example: latency
        metadata:
          type: object
          description: Object with metadata.
        outputColumnName:
          type: string
          description: Name of the column with the model outputs.
          example: output
        prompt:
          type: array
          description: Prompt for the LLM.
          example:
            - role: user
              content: '{{ user_query }}'
          items:
            type: object
            properties:
              role:
                type: string
                description: Role of the prompt.
                example: user
              content:
                type: string
                description: Content of the prompt.
                example: '{{ user_query }}'
        questionColumnName:
          type: string
          description: >-
            Name of the column with the questions. Applies to RAG use cases.
            Providing the question enables RAG-specific metrics.
          example: question
        timestampColumnName:
          type: string
          description: >-
            Name of the column with the timestamps. Timestamps must be in UNIX
            sec format. If not provided, the upload timestamp is used.
          example: timestamp
        userIdColumnName:
          type: string
          description: Name of the column with the user id.
          nullable: true
          example: user_id
        sessionIdColumnName:
          type: string
          description: Name of the column with the session id.
          nullable: true
          example: session_id
      required:
        - outputColumnName
    TabularClassificationData:
      title: Tabular classification
      type: object
      properties:
        categoricalFeatureNames:
          type: array
          description: >-
            Array with the names of all categorical features in the dataset.
            E.g. ["Age", "Geography"].
          example:
            - Geography
          items:
            type: string
        classNames:
          type: array
          description: >-
            List of class names indexed by label integer in the dataset. E.g.
            ["Retained", "Exited"] when 0, 1 are in your label column.
          example:
            - Retained
            - Exited
          items:
            type: string
        featureNames:
          type: array
          description: Array with all input feature names.
          example:
            - Age
            - Geography
          items:
            type: string
        inferenceIdColumnName:
          type: string
          description: >-
            Name of the column with the inference ids. This is useful if you
            want to update rows at a later point in time. If not provided, a
            unique id is generated by Openlayer.
          example: id
        labelColumnName:
          type: string
          description: >-
            Name of the column with the labels. The data in this column must be
            **zero-indexed integers**, matching the list provided in
            `classNames`.
          example: label
        latencyColumnName:
          type: string
          description: Name of the column with the latencies.
          example: latency
        metadata:
          type: object
          description: Object with metadata.
        predictionsColumnName:
          type: string
          description: >-
            Name of the column with the model's predictions as **zero-indexed
            integers**.
          example: prediction
        predictionScoresColumnName:
          type: string
          description: >-
            Name of the column with the model's predictions as **lists of class
            probabilities**.
          example: prediction_scores
        timestampColumnName:
          type: string
          description: >-
            Name of the column with the timestamps. Timestamps must be in UNIX
            sec format. If not provided, the upload timestamp is used.
          example: timestamp
      required:
        - classNames
    TabularRegressionData:
      title: Tabular regression
      type: object
      properties:
        categoricalFeatureNames:
          type: array
          description: >-
            Array with the names of all categorical features in the dataset.
            E.g. ["Gender", "Geography"].
          example:
            - Gender
            - Geography
          items:
            type: string
        featureNames:
          type: array
          description: Array with all input feature names.
          items:
            type: string
        inferenceIdColumnName:
          type: string
          description: >-
            Name of the column with the inference ids. This is useful if you
            want to update rows at a later point in time. If not provided, a
            unique id is generated by Openlayer.
          example: id
        latencyColumnName:
          type: string
          description: Name of the column with the latencies.
          example: latency
        metadata:
          type: object
          description: Object with metadata.
        predictionsColumnName:
          type: string
          description: Name of the column with the model's predictions.
          example: prediction
        targetColumnName:
          type: string
          description: Name of the column with the targets (ground truth values).
          example: target
        timestampColumnName:
          type: string
          description: >-
            Name of the column with the timestamps. Timestamps must be in UNIX
            sec format. If not provided, the upload timestamp is used.
          example: timestamp
    TextClassificationData:
      title: Text classification
      type: object
      properties:
        classNames:
          type: array
          description: >-
            List of class names indexed by label integer in the dataset. E.g.
            ["Retained", "Exited"] when 0, 1 are in your label column.
          example:
            - Retained
            - Exited
          items:
            type: string
        inferenceIdColumnName:
          type: string
          description: >-
            Name of the column with the inference ids. This is useful if you
            want to update rows at a later point in time. If not provided, a
            unique id is generated by Openlayer.
          example: id
        labelColumnName:
          type: string
          description: >-
            Name of the column with the labels. The data in this column must be
            **zero-indexed integers**, matching the list provided in
            `classNames`.
          example: label
        latencyColumnName:
          type: string
          description: Name of the column with the latencies.
          example: latency
        metadata:
          type: object
          description: Object with metadata.
        predictionsColumnName:
          type: string
          description: >-
            Name of the column with the model's predictions as **zero-indexed
            integers**.
          example: prediction
        predictionScoresColumnName:
          type: string
          description: >-
            Name of the column with the model's predictions as **lists of class
            probabilities**.
          example: prediction_scores
        textColumnName:
          type: string
          description: Name of the column with the text data.
          example: user_query
        timestampColumnName:
          type: string
          description: >-
            Name of the column with the timestamps. Timestamps must be in UNIX
            sec format. If not provided, the upload timestamp is used.
          example: timestamp
      required:
        - classNames
  responses:
    UnexpectedError:
      description: Unexpected error.
      content:
        application/json:
          schema:
            type: object
            required:
              - code
              - error
            properties:
              code:
                type: integer
                format: int32
              error:
                type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your workspace API key. See [Find your API
        key](https://www.openlayer.com/docs/workspace-and-projects/find-your-api-key)
        for more information.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.