# ChatOpenAI

## Prerequisite

1. An [OpenAI](https://openai.com/) account
2. Create an [API key](https://platform.openai.com/api-keys)

## Setup

1. **Chat Models** > drag **ChatOpenAI** node

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-2627f3a53fb552f36647956265537d09ec5a7a15%2Fimage%20(10)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

2. **Connect Credential** > click **Create New**

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-9ad11174cc567daff947211332da5ffcca596e08%2Fimage_openAI%20(1).png?alt=media" alt="" width="278"><figcaption></figcaption></figure>

2. Fill in the **ChatOpenAI** credential

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-66551af4421577a34ef39f8ebbf200bcd74bcb5d%2Fimage%20(2)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

4. Voila [🎉](https://emojipedia.org/party-popper/), you can now use **ChatOpenAI node** in Tailwinds

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-95fc122a3d8752f66a9856f86a7a516615854372%2Fimage%20(3)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

## Custom base URL and headers

Tailwinds supports using custom base URL and headers for Chat OpenAI. Users can easily use integrations like OpenRouter, TogetherAI and others that support OpenAI API compatibility.

### TogetherAI

1. Refer to official [docs](https://docs.together.ai/docs/openai-api-compatibility#nodejs) from TogetherAI
2. Create a new credential with TogetherAI API key
3. Click **Additional Parameters** on ChatOpenAI node.
4. Change the Base Path:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-ba25dada7e958ff10b32ee5f4bdb7c1552cb970f%2Fimage%20(4)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### Open Router

1. Refer to official [docs](https://openrouter.ai/docs#quick-start) from OpenRouter
2. Create a new credential with OpenRouter API key
3. Click Additional Parameters on ChatOpenAI node
4. Change the Base Path and Base Options:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-6798fc57a237cb6878be564d89f211906db7a471%2Fimage%20(5)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Custom Model

For models that are not supported on ChatOpenAI node, you can use ChatOpenAI Custom for that. This allow users to fill in model name such as `mistralai/Mixtral-8x7B-Instruct-v0.1`

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-a7f2b6841aa006ebf3db3312181b75bb95149868%2Fimage%20(84).png?alt=media" alt=""><figcaption></figcaption></figure>

## Image Upload

You can also allow images to be uploaded and analyzed by LLM. Under the hood, Tailwinds will use [OpenAI Vison ](https://platform.openai.com/docs/guides/vision)model to process the image. Only works with LLMChain, Conversation Chain, ReAct Agent, and Conversational Agent.

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-c4d5738f833fab1ef64988747abf7e9a5eb914a5%2Fimage%20(3)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(2).png?alt=media" alt="" width="332"><figcaption></figcaption></figure>

From the chat interface, you will now see a new image upload button:

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-45c9575797ee74dbebb2da8307d9d04017240b2e%2FUntitled%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-3a4b62d294fc4fe700c129754f17cb72ca170109%2Fimage%20(121).png?alt=media" alt=""><figcaption></figcaption></figure>
