Skip to content

Event Types Detailed

1.1 response.output_item.added

Purpose: Triggered when a new output item is added

Trigger Timing:

  • When starting web search
  • When starting web crawling
  • When starting final answer generation

Data Structure:

json
{
  "type": "response.output_item.added",
  "sequence_number": 1,
  "output_index": 0,
  "item": {
    "id": "ws_1234567890",
    "type": "web_search_call",
    "status": "in_progress"
  }
}

1.2 response.output_item.done

Purpose: Triggered when an output item is completed

Trigger Timing:

  • When web search is completed
  • When web crawling is completed
  • When final answer generation is completed

Data Structure:

json
{
  "type": "response.output_item.done",
  "sequence_number": 5,
  "output_index": 0,
  "item": {
    "id": "ws_1234567890",
    "type": "web_search_call",
    "status": "completed",
    "action": {
      "type": "search",
      "query": "AI technology trends",
      "results": [
        {
          "title": "Latest AI Developments",
          "link": "https://example.com/ai-news",
          "snippet": "Recent advances in artificial intelligence...",
          "position": 1
        }
      ]
    }
  }
}

2.1 response.web_search_call.in_progress

Purpose: Indicates web search is in progress

Data Structure:

json
{
  "type": "response.web_search_call.in_progress",
  "sequence_number": 2,
  "output_index": 0,
  "item_id": "ws_1234567890"
}

2.2 response.web_search_call.searching

Purpose: Indicates active searching phase

Data Structure:

json
{
  "type": "response.web_search_call.searching",
  "sequence_number": 3,
  "output_index": 0,
  "item_id": "ws_1234567890"
}

2.3 response.web_search_call.completed

Purpose: Indicates web search has completed

Data Structure:

json
{
  "type": "response.web_search_call.completed",
  "sequence_number": 4,
  "output_index": 0,
  "item_id": "ws_1234567890"
}

3. Content Generation Events

3.1 response.content_part.added

Purpose: Indicates start of content generation

Data Structure:

json
{
  "type": "response.content_part.added",
  "sequence_number": 6,
  "output_index": 1,
  "item": {
    "id": "content_1234567890",
    "type": "text",
    "status": "in_progress"
  }
}

3.2 response.output_text.delta

Purpose: Streaming text content updates

Data Structure:

json
{
  "type": "response.output_text.delta",
  "sequence_number": 7,
  "output_index": 1,
  "item_id": "content_1234567890",
  "item": {
    "delta": "Based on the search results, "
  }
}

3.3 response.output_text.done

Purpose: Indicates text generation is complete

Data Structure:

json
{
  "type": "response.output_text.done",
  "sequence_number": 20,
  "output_index": 1,
  "item_id": "content_1234567890",
  "item": {
    "text": "Complete generated text content..."
  }
}

4.1 response.cost.final

Purpose: Final cost summary

Data Structure:

json
{
    "type": "response.cost.final",
    "sequence_number": 886,
    "output_index": 279,
    "item": {
        "output_index": 279,
        "sequence_number": 886,
        "total_cost": 0.05522360760000001,
        "type": "response.cost.final"
    }
}

5. Error Events

5.1 error

Purpose: Error information

Data Structure:

json
{
  "type": "error",
  "sequence_number": 99,
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded, please try again later",
    "details": {
      "retry_after": 60
    }
  }
}

Event Processing Best Practices

  1. Sequential Processing: Process events according to sequence_number
  2. Error Handling: Always implement error event handling
  3. State Management: Track output item states using item_id
  4. Content Buffering: Buffer delta events for complete content assembly
  5. Cost Monitoring: Monitor cost events for usage tracking