> ## 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 new model event (deprecated)

> Deprecated. Use `POST /v1/events` with `event_type="model"` instead. The `ModelEvent` schema carries 14 field-level deprecations covering the model-specific fields the generic event route now expresses (`model`, `messages`, `response`, `provider`, `usage`, `cost`, `hyperparameters`, `template`, `template_inputs`, `tools`, `tool_choice`, `response_format`, `duration`, `error`), plus `project` inherited from `LegacyEvent`. The legacy route continues to serve traffic and remaps these fields into `inputs.*` / `outputs.*` before storage.




## OpenAPI

````yaml post /events/model
openapi: 3.0.3
info:
  title: HoneyHive API
  version: 1.0.1
servers:
  - url: https://api.honeyhive.ai
security:
  - BearerAuth: []
paths:
  /events/model:
    post:
      tags:
        - Events
      summary: Create a new model event
      description: Please refer to our instrumentation guide for detailed information
      operationId: createModelEvent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model_event:
                  $ref: '#/components/schemas/CreateModelEvent'
      responses:
        '200':
          description: Model event created
          content:
            application/json:
              schema:
                type: object
                properties:
                  event_id:
                    type: string
                  success:
                    type: boolean
                example:
                  event_id: 7f22137a-6911-4ed3-bc36-110f1dde6b66
                  success: true
      x-codeSamples:
        - lang: python
          label: createModelEvent
          source: >-
            import honeyhive

            from honeyhive.models import components, operations


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



            res =
            s.events.create_model_event(request=operations.CreateModelEventRequestBody(
                model_event=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: createModelEvent
          source: |-
            import { HoneyHive } from "honeyhive";

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

              const res = await sdk.events.createModelEvent({
                modelEvent: {
                  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

````