Skip to content

response API added - #165

Closed
rafasashi wants to merge 1 commit into
orhanerday:mainfrom
rafasashi:main
Closed

rafasashi wants to merge 1 commit into
orhanerday:mainfrom
rafasashi:main

Conversation

@rafasashi

Copy link
Copy Markdown

I have added support for the v1/response API

  • background => true enables background/asynchronous processing.
  • GET /responses/{id} checks the status.
  • POST /responses/{id}/cancel cancels it.
  • stream => true streams output immediately and is not background processing.
$payload = [
    'model' => 'gpt-4.1-mini',
    'input' => 'Process this task in the background.',
    'background' => true,
];
$response = $this->post(
    Url::responsesUrl(),
    $payload
);

The API will return a response ID. You can poll it using:

$responseId = $response['id'];

$status = $this->get(
    Url::responseUrl($responseId)
);

Example polling loop:

do {
    sleep(2);

    $response = $this->get(
        Url::responseUrl($responseId)
    );

    $status = $response['status'];
} while (in_array($status, ['queued', 'in_progress'], true));

if ($status === 'completed') {
    // Process the completed response.
} else {
    // Handle failed or cancelled response.
}

To cancel a background response:

$this->post(
    Url::cancelResponseUrl($responseId),
    []
);

Streaming usage:


$payload = [
    'model' => 'gpt-4.1-mini',
    'input' => 'Stream this response.',
    'stream' => true,
];

@orhanerday

orhanerday commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

The codebase has been updated. Please check v6.0.0. If your issue isn't resolved, please open a new ticket.

https://github.com/orhanerday/open-ai/releases/tag/6.0

@orhanerday orhanerday closed this Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants