OpenAI SDK Support
Gately AI’s API endpoints for chat, language, code, images, and embeddings are fully compatible with OpenAI’s API libraries.
If you have an existing application using OpenAI’s client libraries, you can easily switch to Gately AI by updating the API configuration.
Configuration
import os
import openai
client = openai.OpenAI(
api_key=os.environ.get("TAAM_API_KEY"),
base_url="https://api.gately.ai/v1"
)
Example Usage
Chat Completion
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)
Streaming Responses
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)
Embeddings Generation
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
For a more tailored development experience, check out our official SDK libraries specifically designed for Gately AI.
Found an incompatibility? Contact our support team for assistance.