# Migrating OpenAI SDK to OfoxAI Source: https://ofox.io/docs/integrations/openai-sdk OfoxAI is fully compatible with the OpenAI SDK. Migrating from a direct OpenAI connection requires changing just two parameters: `base_url` and `api_key`. ## Migration Steps ### Just Change Two Lines of Code **Python** ```python from openai import OpenAI # Before: direct OpenAI connection # client = OpenAI(api_key="sk-openai-xxx") # Now: through OfoxAI client = OpenAI( base_url="https://api.ofox.io/v1", # Added api_key="" # Replaced ) # Everything else stays the same! response = client.chat.completions.create( model="openai/gpt-6.1-sol", # Add provider prefix messages=[{"role": "user", "content": "Hello!"}] ) ``` **TypeScript** ```typescript import OpenAI from 'openai' // Before: direct OpenAI connection // const client = new OpenAI({ apiKey: 'sk-openai-xxx' }) // Now: through OfoxAI const client = new OpenAI({ baseURL: 'https://api.ofox.io/v1', // Added apiKey: '' // Replaced }) // Everything else stays the same! ``` ## Model Naming OfoxAI uses the `provider/model-name` format for model identifiers: | OpenAI Original Name | OfoxAI Model ID | |---------------------|-----------------| | `gpt-6.1-sol` | `openai/gpt-6.1-sol` | | `gpt-6-luna` | `openai/gpt-6-luna` | | `gpt-5.5` | `openai/gpt-5.5` | | `text-embedding-3-small` | `openai/text-embedding-3-small` | Through OfoxAI, you can also access models from other providers. For recommended models, see the [OfoxAI Model Marketplace](https://ofox.io/models). ## Compatibility OfoxAI supports the following OpenAI API features: | Feature | Status | |---------|--------| | Chat Completions | ✅ Fully compatible | | Streaming | ✅ Fully compatible | | Function Calling | ✅ Fully compatible | | JSON Mode | ✅ Fully compatible | | Vision (image input) | ✅ Fully compatible | | Embeddings | ✅ Fully compatible | | Models List | ✅ Fully compatible | | Images Generation | ✅ Fully compatible | ## Framework Integration ### LangChain ```python from langchain_openai import ChatOpenAI llm = ChatOpenAI( base_url="https://api.ofox.io/v1", api_key="", model="openai/gpt-6.1-sol" ) ``` ### LlamaIndex ```python from llama_index.llms.openai import OpenAI llm = OpenAI( api_base="https://api.ofox.io/v1", api_key="", model="openai/gpt-6.1-sol" ) ``` ### Vercel AI SDK ```typescript import { createOpenAI } from '@ai-sdk/openai' const ofoxai = createOpenAI({ baseURL: 'https://api.ofox.io/v1', apiKey: '' }) const model = ofoxai('openai/gpt-6.1-sol') ``` Any framework or tool that supports the OpenAI SDK can integrate with OfoxAI by changing the `base_url`.