Skip to main content

Overview

OpenAI Chat Completions API provides access to GPT-4o, GPT-5, and other chat models. This is the standard API for conversational interactions. Model Class: OpenAIChatModel

Authentication

export OPENAI_API_KEY="sk-..."

Examples

from upsonic import Agent, Task
from upsonic.models.openai import OpenAIChatModel

model = OpenAIChatModel(model_name="gpt-4o")
agent = Agent(model=model)

task = Task("Hello, how are you?")
result = agent.do(task)
print(result.output)

Parameters

ParameterTypeDescriptionDefaultSource
max_tokensintMaximum tokens to generateModel-specificBase
temperaturefloatSampling temperature (0.0-2.0)1.0Base
top_pfloatNucleus sampling threshold1.0Base
seedintRandom seed for deterministic outputsNoneBase
stop_sequenceslist[str]Sequences that stop generationNoneBase
presence_penaltyfloatPenalty for token presence (-2.0 to 2.0)0.0Base
frequency_penaltyfloatPenalty for token frequency (-2.0 to 2.0)0.0Base
logit_biasdict[str, int]Modify token likelihoodsNoneBase
parallel_tool_callsboolAllow parallel tool callsTrueBase
timeoutfloatRequest timeout in seconds600Base
extra_headersdict[str, str]Additional HTTP headersNoneBase
extra_bodyobjectAdditional request body paramsNoneBase
openai_reasoning_effort'low' | 'medium' | 'high'Computational effort for reasoning modelsNoneSpecific
openai_logprobsboolInclude log probabilities in responseFalseSpecific
openai_top_logprobsintNumber of top log probs to return (1-20)NoneSpecific
openai_userstrUnique user identifier for abuse monitoringNoneSpecific
openai_service_tier'auto' | 'default' | 'flex' | 'priority'Service tier for request routing’auto’Specific
openai_predictionChatCompletionPredictionContentParamEnable predicted outputsNoneSpecific