Skip to content

Responses

Create a response with streaming support. This endpoint corresponds to OpenAI’s Responses API.

from r9s import R9S
with R9S(api_key=os.getenv("R9S_API_KEY",""),) as r9_s:
res = r9_s.responses.create(model="gpt-4o-mini", input="Tell me a joke about programming", instructions="You are a funny assistant", temperature=0.7, max_output_tokens=500, stream=False)
for event in res:
# handle event
print(event, flush=True)
ParameterTypeRequiredDescription
modelstr:heavy_check_mark:Model name
inputInput:heavy_check_mark:Input content, required parameter. Can be:
- String: Single text input
- Message array: Structured conversation history

Important limitations:
- Messages only support basic fields (role, content, name)
- Does not support tool_calls, tool_call_id and other tool-related fields
- content field is required and cannot be null
- To use tools, define them in the top-level tools parameter; model will call them on first response

Note: Responses API has deprecated messages parameter, now uses input parameter uniformly
instructionsstr:heavy_minus_sign:System-level instructions to guide model behavior and response style (similar to system message)
temperaturefloat:heavy_minus_sign:Controls output randomness, higher values mean more random
top_pfloat:heavy_minus_sign:Nucleus sampling parameter, controls output diversity
max_output_tokensint:heavy_minus_sign:Maximum number of tokens to generate
streambool:heavy_minus_sign:Whether to enable streaming
modalitiesArray<string (text, audio)>:heavy_minus_sign:Response modality types
toolsArray:heavy_minus_sign:Available tools list (using nested format)
tool_choiceobject:heavy_minus_sign:Tool selection strategy
metadataobject:heavy_minus_sign:Additional metadata
retriesobject:heavy_minus_sign:Configuration to override the default retry behavior of the client.

CreateResponseResponse

Error TypeStatus CodeContent Type
errors.BadRequestError400application/json
errors.AuthenticationError401application/json
errors.PermissionDeniedError403application/json
errors.UnprocessableEntityError422application/json
errors.RateLimitError429application/json
errors.InternalServerError500application/json
errors.ServiceUnavailableError503application/json
errors.R9SDefaultError4XX, 5XX*/*