OpenAI

Configure and use OpenAI GPT models through InferXgate.

InferXgate provides full support for OpenAI’s GPT models.

Configuration

OPENAI_API_KEY=sk-...

# Optional: Organization ID
OPENAI_ORG_ID=org-...

Available Models

Model IDDescriptionContext Window
gpt-4-turboLatest GPT-4 Turbo128K
gpt-4GPT-4 base8K
gpt-4-32kGPT-4 extended context32K
gpt-3.5-turboFast and affordable16K

Usage Example

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:3000/v1",
    api_key="your-api-key"
)

response = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[
        {"role": "user", "content": "What is machine learning?"}
    ]
)

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

Function Calling

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get weather for a location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string"}
                },
                "required": ["location"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[{"role": "user", "content": "Weather in Tokyo?"}],
    tools=tools
)

JSON Mode

response = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[{"role": "user", "content": "List 3 colors as JSON"}],
    response_format={"type": "json_object"}
)

Supported Features

  • Chat completions
  • Streaming
  • Function/tool calling
  • JSON mode
  • Vision (GPT-4 Vision)
  • Embeddings

Pricing

ModelInput (per 1M tokens)Output (per 1M tokens)
GPT-4 Turbo$10.00$30.00
GPT-4$30.00$60.00
GPT-3.5 Turbo$0.50$1.50