# Chat Completions **Sync Type: Incremental** ## Overview The OpenAI Chat Completions input fetches stored chat completion records from the OpenAI API for monitoring model usage, token consumption, and content policy events. Only completions created with `store: true` are returned. This integration enables tracking of AI model utilization, cost analysis through token consumption metrics, and auditing of chat interactions across your OpenAI organization. ## Prerequisites ### 1. OpenAI Organization Access - Active OpenAI organization account - API key with access to the Chat Completions API ### 2. Stored Completions Enabled Chat completions must be created with the `store: true` parameter to appear in the API response. Completions created without this flag will not be fetched by this connector. [Learn More](https://developers.openai.com/api/reference/resources/chat/subresources/completions/subresources/messages/methods/list#(resource)%20chat.completions.messages%20%3E%20(method)%20list) ## API Key Setup 1. **Access Settings** - From the OpenAI platform home page, click the **Settings** icon in the top-right corner. 2. **Navigate to API Keys** - In the left navigation panel, select **API Keys**. 3. **Create New Key** - Click the **Create new secret key** button. 4. **Configure Key Settings** - **Name:** Provide a descriptive name (e.g., "Monad Chat Completions"). - **Permissions:** The key needs read access to the Chat Completions API. 5. **Save and Store Key** - Copy the generated API key immediately. - Store it securely - it cannot be retrieved later if lost. ## Configuration ### Settings | Setting | Type | Required | Description | |---------|------|----------|-------------| | Model | string | No | Filter completions by model (e.g. gpt-4o). Leave empty to fetch all models. | | API Rate Limit | object | No | Optional limit on the connector's outbound request rate to the source API. Leave blank to use the connector's default behavior. See [API Rate Limiting](../../../guides/rate-limiting) for the field format, limits, and how to choose a value. | ### Secrets | Secret | Type | Required | Description | |--------|------|----------|-------------| | API Key | string | Yes | The API key generated from the OpenAI platform. | ## Related Articles - [OpenAI Chat Completions API Reference](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/list) - [OpenAI Stored Completions](https://developers.openai.com/api/reference/chat-completions/overview) - [OpenAI Platform](https://platform.openai.com/home) ## Sample Record ```json { "object": "chat.completion", "id": "chatcmpl-e4174b5d-3aa2-c9f9-60c2-2bc7767f826b", "model": "gpt-5.4", "created": 1780074647, "request_id": "req_986cd465-b592-abbc-3607-15c437fbb008", "tool_choice": null, "usage": { "total_tokens": 609, "completion_tokens": 275, "prompt_tokens": 420 }, "seed": 2615205, "top_p": 1.0, "temperature": 1.0, "presence_penalty": 0.0, "frequency_penalty": 0.0, "system_fingerprint": "fp_87dc40bd-273f-1305-ab7f-efd7145c3b59", "input_user": null, "service_tier": "default", "tools": null, "metadata": {}, "choices": [ { "index": 0, "message": { "content": "Hello! How can I help you today?", "role": "assistant", "tool_calls": null, "function_call": null }, "finish_reason": "stop", "logprobs": null } ], "response_format": null } ``` ## Sync frequency By default this input polls approximately every 10 seconds, with each sync beginning after the previous one completes. A cron schedule configured on the pipeline overrides this cadence. See [Input Sync Frequency](../../guides/sync-frequency) for details.