Enable intelligent prediction caching
mainOpenAI-Forward supports caching AI predictions to accelerate access and reduce costs.
When using openai forwarding mode, you can control caching behavior per request using the extra_body parameter in the Python SDK or by adding a caching key to the JSON body in a raw request.
Python SDK Example:
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello!"}],
extra_body={"caching": True}
)Curl Example:
curl https://smart.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-******" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello!"}],
"caching": true
}'client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello!"}],
extra_body={"caching": True}
)