---
sidebar_label: OpenAI
---

import CodeBlock from "@theme/CodeBlock";

# ChatOpenAI

You can use OpenAI's chat models as follows:

import OpenAI from "@examples/models/chat/integration_openai.ts";

<CodeBlock language="typescript">{OpenAI}</CodeBlock>

If you're part of an organization, you can set `process.env.OPENAI_ORGANIZATION` with your OpenAI organization id, or pass it in as `organization` when
initializing the model.

## Custom URLs

You can customize the base URL the SDK sends requests to by passing a `configuration` parameter like this:

import OpenAICustomBase from "@examples/models/chat/integration_openai_custom_base.ts";

<CodeBlock language="typescript">{OpenAICustomBase}</CodeBlock>

You can also pass other `ClientOptions` parameters accepted by the official SDK.

If you are hosting on Azure OpenAI, see the [dedicated page instead](/docs/modules/model_io/models/chat/integrations/azure).

## Calling fine-tuned models

You can call fine-tuned OpenAI models by passing in your corresponding `modelName` parameter.

This generally takes the form of `ft:{OPENAI_MODEL_NAME}:{ORG_NAME}::{MODEL_ID}`. For example:

import OpenAIFineTuned from "@examples/models/chat/integration_openai_fine_tune.ts";

<CodeBlock language="typescript">{OpenAIFineTuned}</CodeBlock>
