Skip to main content

Responses

POST https://gateway-api.mastra.ai/v1/responses
GET https://gateway-api.mastra.ai/v1/responses/{response_id}
DELETE https://gateway-api.mastra.ai/v1/responses/{response_id}
GET https://gateway-api.mastra.ai/v1/responses/{response_id}/input_items

Compatible with the OpenAI Responses API.

Create a response
Direct link to Create a response

import OpenAI from 'openai'

const client = new OpenAI({
apiKey: process.env.MASTRA_GATEWAY_API_KEY,
baseURL: 'https://gateway-api.mastra.ai/v1',
})

const response = await client.responses.create({
model: 'openai/gpt-6.1-sol',
input: 'Write a haiku about routers.',
})

console.log(response.output_text)

Continue a conversation
Direct link to Continue a conversation

Pass previous_response_id to continue from a stored response:

const followUp = await client.responses.create({
model: 'openai/gpt-6.1-sol',
previous_response_id: response.id,
input: 'Now make it rhyme.',
})

Stored responses live with the provider that created them. Gateway sends a continuation back to the same provider route, so a continuation doesn't fail over to a different provider. Retrieving, deleting, and listing input items for a stored response isn't billed.

Gateway response IDs belong to your organization. Another organization's key can't read them.

On this page