Agent Framework OpenAI

raw JSON →
1.3.0 verified Sat May 09 auth: no python

Provides OpenAI model integrations for the Microsoft Agent Framework. Current version 1.3.0, weekly releases on PyPI. Requires Python >=3.10.

pip install agent-framework-openai
error ImportError: cannot import name 'OpenAIAgent' from 'agent_framework_openai'
cause Outdated library version or wrong import path.
fix
Upgrade to latest version: pip install --upgrade agent-framework-openai. Then use from agent_framework_openai import OpenAIAgent.
error ValueError: Model 'gpt-3.5-turbo-instruct' is not supported. Only ChatCompletion models are allowed.
cause The library only supports models that use the Chat Completions API. Instruct models are not compatible.
fix
Use a ChatCompletion model like 'gpt-4' or 'gpt-3.5-turbo'.
error TypeError: __init__() got an unexpected keyword argument 'openai_api_key'
cause Breaking change in v1.0.0: parameter renamed from `openai_api_key` to `api_key`.
fix
Change parameter name to api_key.
breaking Breaking change: In v1.0.0 the OpenAIAgent constructor changed from accepting `openai_api_key` to `api_key`. Existing code using the old parameter name will fail.
fix Replace `openai_api_key=...` with `api_key=...` when initializing OpenAIAgent.
deprecated Deprecated: `agent_framework_openai.tools` submodule is deprecated; use `agent_framework_openai.ToolSet` directly.
fix Replace `from agent_framework_openai.tools import ToolSet` with `from agent_framework_openai import ToolSet`.
gotcha The library only supports OpenAI models; attempting to pass a non-OpenAI model will raise a ValueError. Common mistake: using model names like 'gpt-3.5-turbo-instruct' which are not supported by the ChatCompletion endpoint.
fix Use models from the Chat Completions API (e.g., gpt-4, gpt-4o, gpt-3.5-turbo).

Create an OpenAI-powered agent using the default GPT-4o model.

import os
from agent_framework_openai import OpenAIAgent

agent = OpenAIAgent(
    api_key=os.environ.get('OPENAI_API_KEY', ''),
    model='gpt-4o'
)
response = agent.run("Hello")
print(response)