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

# Create a batch of model events (deprecated)

> Deprecated. Use `POST /v1/events/batch` with `event_type="model"` on each event instead. Migration notes: the top-level array `model_events` becomes `events`; each element must explicitly set `event_type: "model"` (the legacy route sets this server-side); the deprecated top-level aliases `is_single_session` and `session` are not accepted by the v1 route (`PostEventBatchRequest` is `.strict()`); use `single_session` and `session_properties` instead. The legacy route continues to serve traffic and remaps the model-specific fields on each event (`model`, `messages`, `response`, `provider`, `usage`, `cost`, `hyperparameters`, `template`, `template_inputs`, `tools`, `tool_choice`, `response_format`, `duration`, `error`) into `inputs.*` / `outputs.*` before storage.




## OpenAPI

````yaml post /events/model/batch
openapi: 3.0.3
info:
  title: HoneyHive API
  version: 1.0.1
servers:
  - url: https://api.honeyhive.ai
security:
  - BearerAuth: []
paths:
  /events/model/batch:
    post:
      tags:
        - Events
      summary: Create a batch of model events
      description: Please refer to our instrumentation guide for detailed information
      operationId: createModelEventBatch
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model_events:
                  type: array
                  items:
                    $ref: '#/components/schemas/CreateModelEvent'
      responses:
        '200':
          description: Model events created
          content:
            application/json:
              schema:
                type: object
                properties:
                  event_ids:
                    type: array
                    items:
                      type: string
                  success:
                    type: boolean
                example:
                  event_ids:
                    - 7f22137a-6911-4ed3-bc36-110f1dde6b66
                    - 7f22137a-6911-4ed3-bc36-110f1dde6b67
                  success: true
        '500':
          description: Model events partially created
          content:
            application/json:
              schema:
                type: object
                properties:
                  event_ids:
                    type: array
                    items:
                      type: string
                  errors:
                    type: array
                    items:
                      type: string
                      description: >-
                        Any failure messages for events that could not be
                        created
                  success:
                    type: boolean
                example:
                  event_ids:
                    - 7f22137a-6911-4ed3-bc36-110f1dde6b66
                    - 7f22137a-6911-4ed3-bc36-110f1dde6b67
                  errors:
                    - Could not create event due to missing model
                    - Could not create event due to missing provider
                  success: true
      x-codeSamples:
        - lang: python
          label: createModelEventBatch
          source: >-
            import honeyhive

            from honeyhive.models import components, operations


            s = honeyhive.HoneyHive(
                bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
            )



            res =
            s.events.create_model_event_batch(request=operations.CreateModelEventBatchRequestBody(
                model_events=[
                    components.CreateModelEvent(
                        project='New Project',
                        model='gpt-4o',
                        provider='openai',
                        messages=[
                            {
                                'role': 'system',
                                'content': 'Hello, world!',
                            },
                        ],
                        response={
                            'role': 'assistant',
                            'content': 'Hello, world!',
                        },
                        duration=42,
                        usage={
                            'prompt_tokens': 10,
                            'completion_tokens': 10,
                            'total_tokens': 20,
                        },
                        cost=0.00008,
                        error=None,
                        source='playground',
                        event_name='Model Completion',
                        hyperparameters={
                            'temperature': 0,
                            'top_p': 1,
                            'max_tokens': 1000,
                            'presence_penalty': 0,
                            'frequency_penalty': 0,
                            'stop': [
                                '<value>',
                            ],
                            'n': 1,
                        },
                        template=[
                            {
                                'role': 'system',
                                'content': 'Hello, {{ name }}!',
                            },
                        ],
                        template_inputs={
                            'name': 'world',
                        },
                        tools=[
                            {
                                'key': '<value>',
                            },
                        ],
                        tool_choice='none',
                        response_format={
                            'type': 'text',
                        },
                    ),
                ],
            ))


            if res.object is not None:
                # handle response
                pass
        - lang: typescript
          label: createModelEventBatch
          source: |-
            import { HoneyHive } from "honeyhive";

            async function run() {
              const sdk = new HoneyHive({
                bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
              });

              const res = await sdk.events.createModelEventBatch({
                modelEvents: [
                  {
                    project: "New Project",
                    model: "gpt-4o",
                    provider: "openai",
                    messages: [
                      {
                        "role": "system",
                        "content": "Hello, world!",
                      },
                    ],
                    response: {
                      "role": "assistant",
                      "content": "Hello, world!",
                    },
                    duration: 42,
                    usage: {
                      "prompt_tokens": 10,
                      "completion_tokens": 10,
                      "total_tokens": 20,
                    },
                    cost: 0.00008,
                    error: null,
                    source: "playground",
                    eventName: "Model Completion",
                    hyperparameters: {
                      "temperature": 0,
                      "top_p": 1,
                      "max_tokens": 1000,
                      "presence_penalty": 0,
                      "frequency_penalty": 0,
                      "stop": [
                        "<value>",
                      ],
                      "n": 1,
                    },
                    template: [
                      {
                        "role": "system",
                        "content": "Hello, {{ name }}!",
                      },
                    ],
                    templateInputs: {
                      "name": "world",
                    },
                    tools: [
                      {
                        "key": "<value>",
                      },
                    ],
                    toolChoice: "none",
                    responseFormat: {
                      "type": "text",
                    },
                  },
                ],
              });

              if (res.statusCode == 200) {
                // handle response
              }
            }

            run();
components:
  schemas:
    CreateModelEvent:
      type: object
      properties:
        project:
          type: string
          description: Project associated with the event
        model:
          type: string
          description: Model name
        provider:
          type: string
          description: Model provider
        messages:
          type: array
          items:
            type: object
            additionalProperties: true
          description: Messages passed to the model
        response:
          type: object
          additionalProperties: true
          description: Final output JSON of the event
        duration:
          type: number
          description: How long the event took in milliseconds
        usage:
          type: object
          additionalProperties: true
          description: Usage statistics of the model
        cost:
          type: number
          description: Cost of the model completion
        error:
          type: string
          description: Any error description if event failed
        source:
          type: string
          description: Source of the event - production, staging, etc
        event_name:
          type: string
          description: Name of the event
        hyperparameters:
          type: object
          additionalProperties: true
          description: Hyperparameters used for the model
        template:
          type: array
          items:
            type: object
            additionalProperties: true
          description: Template used for the model
        template_inputs:
          type: object
          additionalProperties: true
          description: Inputs for the template
        tools:
          type: array
          items:
            type: object
            additionalProperties: true
          description: Tools used for the model
        tool_choice:
          type: string
          description: Tool choice for the model
        response_format:
          type: object
          additionalProperties: true
          description: Response format for the model
      required:
        - project
        - model
        - provider
        - messages
        - response
        - duration
        - usage
      example:
        project: New Project
        model: gpt-4o
        provider: openai
        messages:
          - role: system
            content: Hello, world!
        response:
          role: assistant
          content: Hello, world!
        duration: 42
        usage:
          prompt_tokens: 10
          completion_tokens: 10
          total_tokens: 20
        cost: 0.00008
        error: null
        source: playground
        event_name: Model Completion
        hyperparameters:
          temperature: 0
          top_p: 1
          max_tokens: 1000
          presence_penalty: 0
          frequency_penalty: 0
          stop: []
          'n': 1
        template:
          - role: system
            content: Hello, {{ name }}!
        template_inputs:
          name: world
        tools:
          type: function
          function:
            name: get_current_weather
            description: Get the current weather
            parameters:
              type: object
              properties:
                location:
                  type: string
                  description: The city and state, e.g. San Francisco, CA
                format:
                  type: string
                  enum:
                    - celsius
                    - fahrenheit
                  description: >-
                    The temperature unit to use. Infer this from the users
                    location.
              required:
                - location
                - format
        tool_choice: none
        response_format:
          type: text
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````