# OpenAI

API configuration: [`openai`](https://terapi.dev/providers.yaml)

### Features

| Features                                                                                                                                        | Status                        |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
| [Auth (API Key)](https://github.com/shahab-bahojb-basketAsia/terapi-docs/blob/main/integrate/guides/authorize-an-api/README.md)                 | ✅                             |
| [Sync data](https://github.com/shahab-bahojb-basketAsia/terapi-docs/blob/main/integrate/guides/sync-data-from-an-api/README.md)                 | ✅                             |
| [Perform workflows](https://github.com/shahab-bahojb-basketAsia/terapi-docs/blob/main/integrate/guides/perform-workflows-with-an-api/README.md) | ✅                             |
| [Proxy requests](https://github.com/shahab-bahojb-basketAsia/terapi-docs/blob/main/integrate/guides/proxy-requests-to-an-api/README.md)         | ✅                             |
| [Receive webhooks](https://github.com/shahab-bahojb-basketAsia/terapi-docs/blob/main/integrate/guides/receive-webhooks-from-an-api/README.md)   | 🚫 (time to contribute: <48h) |

We can implement missing features in <48h, just ask for it in the [community](https://terapi.dev/slack).

### Getting started

* [Generate an API key in your OpenAI account](https://platform.openai.com/api-keys)
* [OpenAI API docs](https://platform.openai.com/docs/api-reference/introduction)
* [OpenAI Authentication](https://platform.openai.com/docs/api-reference/authentication)
* [OpenAI rate limits](https://platform.openai.com/docs/guides/rate-limits)

Need help getting started? Get help in the [community](https://terapi.dev/slack).

### API gotchas

* OpenAI uses API\_KEY auth mode with `Authorization: Bearer API_KEY` in the request header to access different endpoints.
* terapi supports automatic retries based on the `x-ratelimit-reset-requests` header from OpenAI's API. This header indicates when the request limit will reset, allowing terapi to efficiently manage API calls. Unlike `x-ratelimit-reset-tokens`, which pertains to the total token usage,`x-ratelimit-reset-requests` specifically addresses the number of API requests.
* For users associated with multiple organizations or accessing their projects via a legacy user API key, optional headers can be included to specify the organization and project for the API request. Organization IDs can be found on your [Organization settings](https://platform.openai.com/account/organization) page, while project IDs can be found on your [General settings](https://platform.openai.com/settings) page.
* This can be done at the script level:

```js
const config:ProxyConfiguration = {
    endpoint: '/v1/models',
    headers: {
        'OpenAI-Organization': $organizationId,
        'OpenAI-Project': $projectId
    }
};
```

Add Getting Started links and Gotchas by [editing this page](https://github.com/terapihq/terapi/tree/master/docs-v2/integrations/all/openai.mdx)
