Skip to content

Add the possibility to add extra body fields in the RunConfig or Agents #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lucas-trueffles opened this issue Apr 13, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@lucas-trueffles
Copy link

The standard openai package it is possible to add additional fields to the request body. This is particularly useful if you have some kind of proxy which can process additional data for metrics, tracing or FinOps.

Here an example how to do it in the openai package:

import openai
client = openai.OpenAI()

response = client.chat.completions.create(model="gpt-4o", messages = [
    {
        "role": "user",
        "content": "Write a short poem about GitHub"
    }
], 
# it is possible to send additional body fields with "extra_body"
    extra_body={
      "field1": "value 1"
    }
) 

Unfortunately I wasn't able to find a way to mimic this behaviour.

I would suggest to add the feature to provide extra body fields in the RunConfig:
result = Runner.run_sync(agent, input="Say this is a test", run_config=RunConfig(extra_body={"field1":"value 1"}))

Maybe it would also benefit if you can set extra body fields on a per agent basis.
agent = Agent(name="Assistant", instructions="You are a helpful assistant", extra_body={"field1":"value 1"})
These will then be added on top of the extra fields which have been set in the RunConfig.

@lucas-trueffles lucas-trueffles added the enhancement New feature or request label Apr 13, 2025
@rm-openai
Copy link
Collaborator

Makes sense. I think it belongs on ModelSettings; PR welcome!

@DanieleMorotti
Copy link
Contributor

I submitted a PR #500 , also adding extra_query parameter. Tell me if this implementation is okay for you.

rm-openai pushed a commit that referenced this issue Apr 14, 2025
Added the possibility to pass `extra_query` and `extra_body` parameters
when sending a request.
In this implementation I added the attributes to `ModelSettings` as
suggested by @rm-openai in #487 .

I'll be happy to add some tests if you have any suggestions.
@rm-openai
Copy link
Collaborator

Thanks @DanieleMorotti for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants