# \`Json\` response type in Assistant

**URL:** <https://community.openai.com/t/json-response-type-in-assistant/726282>\
**Category:** API\
**Tags:** api\
**Created:** [April 24, 2024, 8:07am UTC](https://community.openai.com/t/json-response-type-in-assistant/726282 "2024-04-24T08:07:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayansengupta17](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ayansengupta17/32/373232_2.png) [@ayansengupta17](https://community.openai.com/u/ayansengupta17)\
**Post date:** [April 24, 2024, 8:07am UTC](https://community.openai.com/t/json-response-type-in-assistant/726282/1 "2024-04-24T08:07:29Z")

</div>

Recent updates to OpenAI assistant allows us to have output from Assistant in json mode.

I am getting bad request error:

```auto
openai.BadRequestError: Error code: 400 - {'error': {'message': 'Runs with `response_format` of type `json_object` type are only compatible if all tools are type `function`.', 'type': 'invalid_request_error', 'param': 'response_format', 'code': None}}

```

If I try to create an assistant in Python using:

```auto
assistant = client.beta.assistants.create(
        name=f"Test Assistant",
        instructions=<SOME INSTRUCTION>,
        model=model_name,
        tools=[{"type": "code_interpreter"}],
        temperature=0.2,
        response_format={"type": "json_object"},
    )

```

It seems you can’t use tool code interpretor if you want to use json\_mode as response. I am not sure about why such a restriction exists.

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [April 24, 2024, 10:04am UTC](https://community.openai.com/t/json-response-type-in-assistant/726282/2 "2024-04-24T10:04:47Z")

</div>

> [@ayansengupta17](#):
>
> I am not sure about why such a restriction exists.

- Code interpreter is powered by a tool called python, not a tool for all functions
- The `python` tool internal to assistants does not take output with arguments in json
- The response\_format would affect all AI generation after the AI emits tokens for tools or to decide to respond to the user.
- The result would be python receiving a loop of tabs or linefeeds until the max\_tokens is hit, getting an error return, and then trying again multiple times.
