#Support for OpenAI's new Responses API?

1 messages · Page 1 of 1 (latest)

cloud falcon
#

Howdy CopilotKit team! I updated my langgraph backend to use OpenAI's new responses API (https://community.openai.com/t/introducing-the-responses-api/1140929) and I noticed some interesting behavior in the CopilotChat. While responses are streaming back, I see 5 message boxes on the front end, 2 of which show the streaming response and the other 3 empty. When the streaming finishes we are back to the correct single chat response in one message box. I suspect because the API is so new its not really supported yet. Could you confirm that is the case? Or is it possible I just need to specify a different serviceAdapter to copilotRuntimeNextJSAppRouterEndpoint()? I'm currently using:

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const serviceAdapter = new OpenAIAdapter({ openai });

I can work around this by NOT using the new responses API but it has useful features I'd like to use. Thank you for your time! 🙂

OpenAI Developer Community

We’re making improvements to how you build assistants and use tools with the OpenAI API. Based on your feedback from the Assistants API beta, we’ve built the Responses API — a faster, more flexible, and easier way to create agentic experiences that combines the simplicity of Chat Completions with the tool use and state management of the As...

hidden crystal
#

Hi @cloud falcon, CopilotKit doesn’t natively support OpenAI’s new Responses API yet, so you’re seeing this behaviour because the built-in OpenAIAdapter only streams from the old Chat Completions API.

cloud falcon
#

Makes sense. Is it on the road map at all? I'm juggling a bunch of tasks at the moment but perhaps this is something I could help implement? I'll take a look at the OpenAIAdapter implementation.

hidden crystal
#

@cloud falcon Absolutely! We welcome all contributions from the community.
Could you also create a GitHub issue for this? That way, the team can track it and prioritize based on the demand.

foggy orchid
#

Hey @hidden crystal - OpenAI is pushing their Responses API hard. Curious what your teams perspective is on supporting it? I'm mainly interested in access reasoning traces or summaries when building agents because it brings a lot of benefits around UX and context management. How are you seeing customers do this without support for this API? Are there paths to access separated reasoning traces/summaries with Anthropic or other models while using CPK?

muted dust
#

I'm also coming back to this. Does NO ONE know how OpenAI's forced migration away from Assistants is supposed to be implemented with CopilotKit?
Writing a custom adapter from scratch can't possibly be the answer, right?
A YEAR after OpenAI makes the OpenAIAssistantsAdapter obsolete, CopilotKit STILL doesn't have a solution?!

That's can't be real, surely.
Why even bother writing the Assistants adapter if you're not going to update it with something usable when OpenAI kills support for it?

#

And if an adapter is actually necessary, why can't I find even a single example adapter doing so?

red cairn
#

Hey @muted dust, thanks for the question, and the answer isn't a new adapter. It moved up a layer.

The v1 service adapters (OpenAIAdapter, OpenAIAssistantAdapter) are model-specific code. Every time OpenAI ships a new API shape, that pattern breaks, which is exactly the what AG-UI is solving.

The supported path now is AG-UI agents + useAgent from @copilotkit/react-core/v2. The agent owns the LLM call.

CopilotKit just routes events. So "which OpenAI API are you using" becomes a detail of your agent - not something CopilotKit has to ship an adapter for.

#

For a LangGraph backend: you don't need an OpenAI service adapter at all. The serviceAdapter arg is still required by the function signature, but when an agent is registered it's not the thing producing responses - the LangGraphAgent is. Swap to ExperimentalEmptyAdapter:

import { ExperimentalEmptyAdapter } from "@copilotkit/runtime";

  const serviceAdapter = new ExperimentalEmptyAdapter(); 
  const runtime = new CopilotRuntime({
    agents: {                           
      my_agent: new LangGraphAgent({ deploymentUrl, graphId: "my_agent" }),
    },                                                   
  });

Then turn on the Responses API where it actually belongs - inside your LangGraph node:

  new ChatOpenAI({
    model: "o4-mini",                
    useResponsesApi: true,
    reasoning: { effort: "high", summary: "auto" },      
  });    
#

That's it. The streaming bug goes away because the legacy adapter isn't in the path anymore.

#

For pure OpenAI without LangGraph: extend AbstractAgent from @ag-ui/client and implement run().

There's a working reference in the AG-UI repo (@ag-ui/openai), and the quickstart walks through it with chat.completions - same pattern works against responses.create. Emit RUN_STARTED, streamTEXT_MESSAGE_CHUNK events, then RUN_FINISHED. Probably 50 lines of code.