> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gately.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Compatibility

> Use OpenAI SDKs with Gately AI

<Frame>
  <img src="https://mintcdn.com/taamai-c8c27d6c/7tpU7wOp-rlopJuB/images/Taamcloud.png?fit=max&auto=format&n=7tpU7wOp-rlopJuB&q=85&s=4bb63ae407c3f5f72f8298b8c49064e4" alt="OpenAI Compatibility" width="1200" height="630" data-path="images/Taamcloud.png" />
</Frame>

## OpenAI SDK Support

<Info>
  Gately AI's API endpoints for chat, language, code, images, and embeddings are fully compatible with OpenAI's API libraries.
</Info>

If you have an existing application using OpenAI's client libraries, you can easily switch to Gately AI by updating the API configuration.

## Configuration

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    import os
    import openai

    client = openai.OpenAI(
      api_key=os.environ.get("TAAM_API_KEY"),
      base_url="https://api.gately.ai/v1"
    )
    ```
  </Tab>

  <Tab title="Node.js">
    ```typescript theme={null}
    import OpenAI from 'openai';

    const client = new OpenAI({
      apiKey: process.env.TAAM_API_KEY,
      baseURL: 'https://api.gately.ai/v1'
    });
    ```
  </Tab>
</Tabs>

<Note>
  Find your API key in the [Developer Settings](https://app.gately.ai/dashboard/settings/organization/developers).
</Note>

## Example Usage

### Chat Completion

<CodeGroup>
  ```python Python theme={null}
  import os
  import openai

  client = openai.OpenAI(
    api_key=os.environ.get("TAAM_API_KEY"),
    base_url="https://api.gately.ai/v1"
  )

  response = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[
      {"role": "system", "content": "You are a travel agent. Be descriptive and helpful."},
      {"role": "user", "content": "Tell me the top 3 things to do in San Francisco"}
    ]
  )

  print(response.choices[0].message.content)
  ```

  ```typescript TypeScript theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: process.env.TAAM_API_KEY,
    baseURL: 'https://api.gately.ai/v1'
  });

  const response = await client.chat.completions.create({
    model: "gpt-4-turbo",
    messages: [
      {role: "system", content: "You are a travel agent. Be descriptive and helpful."},
      {role: "user", content: "Tell me the top 3 things to do in San Francisco"}
    ]
  });

  console.log(response.choices[0].message.content);
  ```
</CodeGroup>

### Streaming Responses

<CodeGroup>
  ```python Python theme={null}
  stream = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[
      {"role": "system", content: "You are a travel agent."},
      {"role": "user", content: "Tell me about San Francisco"}
    ],
    stream=True
  )

  for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="", flush=True)
  ```

  ```typescript TypeScript theme={null}
  const stream = await client.chat.completions.create({
    model: "gpt-4-turbo",
    messages: [
      {role: "system", content: "You are a travel agent."},
      {role: "user", content: "Tell me about San Francisco"}
    ],
    stream: true
  });

  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || "");
  }
  ```
</CodeGroup>

### Embeddings Generation

```python theme={null}
response = client.embeddings.create(
  model="text-embedding-3-small",
  input="Our solar system orbits the Milky Way galaxy at about 515,000 mph"
)

print(response.data[0].embedding)
```

## Native SDKs

<Info>
  For a more tailored development experience, check out our official [SDK libraries](/api-reference/sdk-installation) specifically designed for Gately AI.
</Info>

<CardGroup cols={2}>
  <Card title="Python SDK" icon="python" href="/api-reference/sdk-installation">
    `pip install taam-cloud==1.0.0`
  </Card>

  <Card title="Node.js SDK" icon="js" href="/api-reference/sdk-installation">
    `npm install taam-cloud@0.1.0-alpha.3`
  </Card>
</CardGroup>

## Community Support

<CardGroup cols={2}>
  <Card title="Third-party Libraries" icon="puzzle-piece">
    Compatible with most community-built OpenAI SDK wrappers
  </Card>

  <Card title="Support" icon="headset" href="https://discord.gg/taamcloud">
    Get help with SDK integration in our Discord
  </Card>
</CardGroup>

<Warning>
  Found an incompatibility? Contact our [support team](mailto:support@taam.cloud) for assistance.
</Warning>
