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

# OpenAI Python SDK

> Use the official OpenAI Python SDK with Eden AI to access 500+ AI models through a familiar interface.

export const TechArticleSchema = ({title, description, path, articleSection, about, proficiencyLevel = "Beginner", dependencies, keywords = [], datePublished, dateModified, image, inLanguage = "en"}) => {
  const baseUrl = "https://www.edenai.co/docs";
  const canonicalUrl = `${baseUrl}/${path}`.replace(/\/+$/, "");
  const ogParams = new URLSearchParams({
    division: articleSection || "",
    title: title || "",
    description: description || ""
  });
  const resolvedImage = image || `https://edenai.mintlify.app/_mintlify/api/og?${ogParams.toString()}`;
  const data = {
    "@context": "https://schema.org",
    "@type": "TechArticle",
    "@id": `${canonicalUrl}#techarticle`,
    mainEntityOfPage: {
      "@type": "WebPage",
      "@id": canonicalUrl
    },
    headline: title,
    name: title,
    description: description,
    url: canonicalUrl,
    inLanguage: inLanguage,
    isPartOf: {
      "@type": "WebSite",
      name: "Eden AI Documentation",
      url: baseUrl
    },
    author: [{
      "@type": "Organization",
      name: "Eden AI",
      url: "https://www.edenai.co/"
    }],
    publisher: {
      "@type": "Organization",
      name: "Eden AI",
      url: "https://www.edenai.co/",
      logo: {
        "@type": "ImageObject",
        url: "https://www.edenai.co/assets/logo.png"
      }
    }
  };
  if (articleSection) data.articleSection = articleSection;
  if (about) data.about = {
    "@type": "Thing",
    name: about
  };
  if (proficiencyLevel) data.proficiencyLevel = proficiencyLevel;
  if (dependencies) data.dependencies = dependencies;
  if (keywords && keywords.length) data.keywords = keywords;
  if (datePublished) data.datePublished = datePublished;
  if (dateModified) data.dateModified = dateModified;
  data.image = Array.isArray(resolvedImage) ? resolvedImage : [resolvedImage];
  const json = JSON.stringify(data);
  const schemaId = `techarticle-${canonicalUrl}`;
  React.useEffect(() => {
    if (typeof document === "undefined") return;
    document.querySelectorAll(`script[data-schema-id="${schemaId}"]`).forEach(n => n.remove());
    const script = document.createElement("script");
    script.type = "application/ld+json";
    script.dataset.schemaId = schemaId;
    script.textContent = json;
    document.head.appendChild(script);
    return () => script.remove();
  }, [json, schemaId]);
  return null;
};

<TechArticleSchema title={"OpenAI Python SDK"} description={"Use the official OpenAI Python SDK with Eden AI to access 500+ AI models through a familiar interface."} path="v3/integrations/openai-sdk-python" articleSection="AI Frameworks" about={"LLM Framework Integration"} proficiencyLevel="Intermediate" keywords={["Eden AI", "AI API", "OpenAI SDK", "Python"]} datePublished="2026-05-06T00:00:00Z" dateModified="2026-05-07T00:00:00Z" />

Use the official OpenAI Python SDK with Eden AI to access 500+ AI models through a familiar interface.

## Overview

The OpenAI Python SDK is fully compatible with Eden AI's V3 API. Simply point the SDK to Eden AI's endpoint and you can access models from OpenAI, Anthropic, Google, Cohere, Meta, and more.

## Installation

<CodeGroup>
  ```bash pip theme={null}
  pip install openai
  ```

  ```bash poetry theme={null}
  poetry add openai
  ```
</CodeGroup>

## Quick Start

Configure the OpenAI client to use Eden AI:

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

  client = OpenAI(
      api_key="YOUR_EDEN_AI_API_KEY",  # Get from https://app.edenai.run
      base_url="https://api.edenai.run/v3"
  )

  response = client.chat.completions.create(
      model="openai/gpt-4",
      messages=[
          {"role": "user", "content": "Hello! How are you?"}
      ]
  )

  print(response.choices[0].message.content)
  ```
</CodeGroup>

## Available Models

Access models from multiple providers using the `provider/model` format:

**OpenAI**

* `openai/gpt-4`
* `openai/gpt-4-turbo`
* `openai/gpt-4o`
* `openai/gpt-3.5-turbo`

**Anthropic**

* `anthropic/claude-sonnet-4-5`
* `anthropic/claude-opus-4-5`
* `anthropic/claude-haiku-4-5`

**Google**

* `google/gemini-2.5-pro`
* `google/gemini-2.5-flash`

**Cohere**

* `cohere/command-r-plus`
* `cohere/command-r`

**Meta**

* `meta/llama-3-70b`
* `meta/llama-3-8b`

## Multi-Turn Conversations

Build conversational applications with message history:

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

  client = OpenAI(
      api_key="YOUR_EDEN_AI_API_KEY",
      base_url="https://api.edenai.run/v3"
  )

  messages = [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is the capital of France?"}
  ]

  response = client.chat.completions.create(
      model="anthropic/claude-sonnet-4-5",
      messages=messages
  )

  assistant_response = response.choices[0].message.content
  print(assistant_response)

  # Add assistant response to history
  messages.append({"role": "assistant", "content": assistant_response})

  # Continue conversation
  messages.append({"role": "user", "content": "What's the population?"})

  response = client.chat.completions.create(
      model="anthropic/claude-sonnet-4-5",
      messages=messages
  )

  print(response.choices[0].message.content)
  ```
</CodeGroup>

## Vision Capabilities

Send images to vision-capable models:

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI
  import requests

  client = OpenAI(
      api_key="YOUR_EDEN_AI_API_KEY",
      base_url="https://api.edenai.run/v3"
  )

  # First, upload the image to get a file_id
  upload_response = requests.post(
      "https://api.edenai.run/v3/upload",
      headers={"Authorization": f"Bearer YOUR_EDEN_AI_API_KEY"},
      files={"file": open("image.jpg", "rb")}
  )
  file_id = upload_response.json()["file_id"]

  # Use the file_id in a chat message
  response = client.chat.completions.create(
      model="openai/gpt-4o",
      messages=[
          {
              "role": "user",
              "content": [
                  {"type": "text", "text": "What's in this image?"},
                  {"type": "file", "file": {"file_id": file_id}}
              ]
          }
      ]
  )

  print(response.choices[0].message.content)
  ```
</CodeGroup>

## Error Handling

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

  client = OpenAI(
      api_key="YOUR_EDEN_AI_API_KEY",
      base_url="https://api.edenai.run/v3"
  )

  try:
      response = client.chat.completions.create(
          model="openai/gpt-4",
          messages=[{"role": "user", "content": "Hello!"}]
      )

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

  except openai.AuthenticationError as e:
      print(f"Authentication failed: {e}")
  except openai.RateLimitError as e:
      print(f"Rate limit exceeded: {e}")
  except openai.APIError as e:
      print(f"API error: {e}")
  ```
</CodeGroup>

## Environment Variables

<CodeGroup>
  ```bash .env theme={null}
  EDEN_AI_API_KEY=your_api_key_here
  ```

  ```python Python theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.getenv("EDEN_AI_API_KEY"),
      base_url="https://api.edenai.run/v3"
  )
  ```
</CodeGroup>

## Next Steps

* [Chat Completions](/v3/llms/chat-completions) - Core LLM endpoint
* [File Attachments](/v3/llms/file-upload) - Working with images and documents
* [List LLM Models](/v3/llms/listing-models) - Browse available providers and models
