> ## Documentation Index
> Fetch the complete documentation index at: https://docs.veadk.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Run an agent with SSE

> Return text/event-stream, with each message formatted as data: followed by a JSON event; streaming=true requests incremental model output

`streaming` defaults to false; complete events are still transported using SSE. Successful JSON events use the Event structure; errors after the stream starts are sent as `data: {"error":"..."}`. Use `curl -N` for live output; the interactive request panel may not display individual events as they arrive

Create the session first by default; `--auto_create_session` allows automatic creation. `appName` may be omitted when `ADK_DEFAULT_APP_NAME` is configured

[Create a session](/productions/api-reference/preview/en/agent-api-server/create-session) before submitting a message by default. `streaming` defaults to `false`, which still delivers complete events over SSE; set it to `true` to request incremental model output

<Warning>
  Execution writes session events and can call models, tools, and external resources. Retrying the request can repeat external actions
</Warning>

Each SSE message starts with `data:`, contains JSON, and ends with a blank line. Read continuously with `curl -N`. Events can contain only state or artifact changes rather than text; `partial: true` marks incremental content

```text theme={null}
data: {"content":{"role":"model","parts":[{"text":"Hello"}]},"partial":false,"author":"travel_assistant","invocationId":"invocation-001","id":"event-001","timestamp":1789603200}

data: {"error":"Example execution error"}

```

These examples illustrate message and error event formats; a successful call does not necessarily emit an error. HTTP `200` only indicates that the stream has started. Check for `error` in the stream and continue reading until it closes. The interactive request panel may not display events individually


## OpenAPI

````yaml productions/api-reference/openapi/en/agent-api-server.json POST /run_sse
openapi: 3.1.0
info:
  title: Agent API Server
  version: google-adk 2.2.0
  description: >-
    Public HTTP endpoints for Google ADK 2.2.0; /dev routes require the
    development UI to be enabled
servers:
  - url: http://localhost:8000
    description: Local server
security: []
tags:
  - name: Service and applications
  - name: Sessions
  - name: Agent execution
  - name: Artifacts
  - name: Memory
  - name: Evaluation · development server
  - name: Debugging · development server
  - name: Compatibility endpoints
paths:
  /run_sse:
    post:
      tags:
        - Agent execution
      summary: Run an agent with SSE
      description: >-
        Return text/event-stream, with each message formatted as data: followed
        by a JSON event; streaming=true requests incremental model output


        `streaming` defaults to false; complete events are still transported
        using SSE. Successful JSON events use the Event structure; errors after
        the stream starts are sent as `data: {"error":"..."}`. Use `curl -N` for
        live output; the interactive request panel may not display individual
        events as they arrive


        Create the session first by default; `--auto_create_session` allows
        automatic creation. `appName` may be omitted when `ADK_DEFAULT_APP_NAME`
        is configured
      operationId: agentApiRunSse
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunAgentRequest'
            example:
              appName: travel_assistant
              userId: user-001
              sessionId: session-001
              newMessage:
                role: user
                parts:
                  - text: Plan a day in Beijing
              streaming: true
        required: true
      responses:
        '200':
          description: Successful response
          content:
            text/event-stream:
              schema:
                type: string
              example: >+
                data:
                {"content":{"role":"model","parts":[{"text":"Hello"}]},"author":"travel_assistant","invocationId":"invocation-001","id":"event-001","timestamp":1789603200}

        '400':
          description: Invalid request or a required service/dependency is unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: Requested resource was not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '422':
          description: Request validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |-
            curl -N -X POST 'http://localhost:8000/run_sse' \
              -H 'Content-Type: application/json' \
              -d '{"appName": "travel_assistant", "userId": "user-001", "sessionId": "session-001", "newMessage": {"role": "user", "parts": [{"text": "Plan a day in Beijing"}]}, "streaming": true}'
components:
  schemas:
    RunAgentRequest:
      properties:
        appName:
          anyOf:
            - type: string
            - type: 'null'
          title: Appname
          description: >-
            Application name; falls back to ADK_DEFAULT_APP_NAME when omitted
            and returns 400 if no default is configured
        userId:
          type: string
          title: Userid
          description: User ID
        sessionId:
          type: string
          title: Sessionid
          description: Session ID
        newMessage:
          anyOf:
            - $ref: '#/components/schemas/Content-Input'
            - type: 'null'
          description: >-
            Input message for this turn; it may be omitted when resuming an
            invocation supported by the application
        streaming:
          type: boolean
          title: Streaming
          default: false
          description: Request incremental model streaming; defaults to false
        stateDelta:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Statedelta
          description: Session state changes to apply
        functionCallEventId:
          anyOf:
            - type: string
            - type: 'null'
          title: Functioncalleventid
          description: >-
            Event ID of the function call, used for streaming function-response
            handling
        invocationId:
          anyOf:
            - type: string
            - type: 'null'
          title: Invocationid
          description: Invocation ID
        customMetadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Custommetadata
          description: Custom metadata
      type: object
      required:
        - userId
        - sessionId
      title: RunAgentRequest
    ApiError:
      type: object
      required:
        - detail
      properties:
        detail:
          type: string
          description: Error details
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          description: Error details
      type: object
      title: HTTPValidationError
    Content-Input:
      properties:
        parts:
          anyOf:
            - items:
                $ref: '#/components/schemas/Part-Input'
              type: array
            - type: 'null'
          title: Parts
          description: Ordered message parts
        role:
          anyOf:
            - type: string
            - type: 'null'
          title: Role
          description: Message role, such as user or model
      additionalProperties: false
      type: object
      title: Content
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
          description: Location of the invalid field
        msg:
          type: string
          title: Message
          description: Validation error message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    Part-Input:
      properties:
        mediaResolution:
          anyOf:
            - $ref: '#/components/schemas/PartMediaResolution'
            - type: 'null'
        codeExecutionResult:
          anyOf:
            - $ref: '#/components/schemas/CodeExecutionResult'
            - type: 'null'
          description: Code execution result
        executableCode:
          anyOf:
            - $ref: '#/components/schemas/ExecutableCode'
            - type: 'null'
          description: Executable code
        fileData:
          anyOf:
            - $ref: '#/components/schemas/FileData'
            - type: 'null'
          description: File content referenced by URI
        functionCall:
          anyOf:
            - $ref: '#/components/schemas/FunctionCall'
            - type: 'null'
          description: Function call requested by the model
        functionResponse:
          anyOf:
            - $ref: '#/components/schemas/FunctionResponse-Input'
            - type: 'null'
          description: Function execution result
        inlineData:
          anyOf:
            - $ref: '#/components/schemas/Blob'
            - type: 'null'
          description: Inline binary content with Base64-encoded data
        text:
          anyOf:
            - type: string
            - type: 'null'
          title: Text
          description: Text content
        thought:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Thought
          description: Whether this is thought content
        thoughtSignature:
          anyOf:
            - type: string
              contentEncoding: base64
              contentMediaType: application/octet-stream
            - type: 'null'
          title: Thoughtsignature
          description: Thought signature for subsequent requests
        videoMetadata:
          anyOf:
            - $ref: '#/components/schemas/VideoMetadata'
            - type: 'null'
          description: Video metadata
        toolCall:
          anyOf:
            - $ref: '#/components/schemas/ToolCall'
            - type: 'null'
        toolResponse:
          anyOf:
            - $ref: '#/components/schemas/ToolResponse'
            - type: 'null'
        partMetadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Partmetadata
      additionalProperties: false
      type: object
      title: Part
    PartMediaResolution:
      properties:
        level:
          anyOf:
            - $ref: '#/components/schemas/PartMediaResolutionLevel'
            - type: 'null'
        numTokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Numtokens
      additionalProperties: false
      type: object
      title: PartMediaResolution
    CodeExecutionResult:
      properties:
        outcome:
          anyOf:
            - $ref: '#/components/schemas/Outcome'
            - type: 'null'
        output:
          anyOf:
            - type: string
            - type: 'null'
          title: Output
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: Identifier
      additionalProperties: false
      type: object
      title: CodeExecutionResult
    ExecutableCode:
      properties:
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
        language:
          anyOf:
            - $ref: '#/components/schemas/Language'
            - type: 'null'
          description: Application definition language
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: Identifier
      additionalProperties: false
      type: object
      title: ExecutableCode
    FileData:
      properties:
        displayName:
          anyOf:
            - type: string
            - type: 'null'
          title: Displayname
        fileUri:
          anyOf:
            - type: string
            - type: 'null'
          title: Fileuri
          description: File URI
        mimeType:
          anyOf:
            - type: string
            - type: 'null'
          title: Mimetype
          description: Content MIME type
      additionalProperties: false
      type: object
      title: FileData
    FunctionCall:
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: Identifier
        args:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Args
          description: Function arguments
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Name
        partialArgs:
          anyOf:
            - items:
                $ref: '#/components/schemas/PartialArg'
              type: array
            - type: 'null'
          title: Partialargs
        willContinue:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Willcontinue
      additionalProperties: false
      type: object
      title: FunctionCall
    FunctionResponse-Input:
      properties:
        willContinue:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Willcontinue
        scheduling:
          anyOf:
            - $ref: '#/components/schemas/FunctionResponseScheduling'
            - type: 'null'
        parts:
          anyOf:
            - items:
                $ref: '#/components/schemas/FunctionResponsePart'
              type: array
            - type: 'null'
          title: Parts
          description: Ordered message parts
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: Identifier
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Name
        response:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Response
          description: Response content
      additionalProperties: false
      type: object
      title: FunctionResponse
    Blob:
      properties:
        data:
          anyOf:
            - type: string
              contentEncoding: base64
              contentMediaType: application/octet-stream
            - type: 'null'
          title: Data
        displayName:
          anyOf:
            - type: string
            - type: 'null'
          title: Displayname
        mimeType:
          anyOf:
            - type: string
            - type: 'null'
          title: Mimetype
          description: Content MIME type
      additionalProperties: false
      type: object
      title: Blob
    VideoMetadata:
      properties:
        endOffset:
          anyOf:
            - type: string
            - type: 'null'
          title: Endoffset
        fps:
          anyOf:
            - type: number
            - type: 'null'
          title: Fps
        startOffset:
          anyOf:
            - type: string
            - type: 'null'
          title: Startoffset
      additionalProperties: false
      type: object
      title: VideoMetadata
    ToolCall:
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: Identifier
        toolType:
          anyOf:
            - $ref: '#/components/schemas/ToolType'
            - type: 'null'
        args:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Args
          description: Function arguments
      additionalProperties: false
      type: object
      title: ToolCall
    ToolResponse:
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: Identifier
        toolType:
          anyOf:
            - $ref: '#/components/schemas/ToolType'
            - type: 'null'
        response:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Response
          description: Response content
      additionalProperties: false
      type: object
      title: ToolResponse
    PartMediaResolutionLevel:
      type: string
      enum:
        - MEDIA_RESOLUTION_UNSPECIFIED
        - MEDIA_RESOLUTION_LOW
        - MEDIA_RESOLUTION_MEDIUM
        - MEDIA_RESOLUTION_HIGH
        - MEDIA_RESOLUTION_ULTRA_HIGH
      title: PartMediaResolutionLevel
    Outcome:
      type: string
      enum:
        - OUTCOME_UNSPECIFIED
        - OUTCOME_OK
        - OUTCOME_FAILED
        - OUTCOME_DEADLINE_EXCEEDED
      title: Outcome
    Language:
      type: string
      enum:
        - LANGUAGE_UNSPECIFIED
        - PYTHON
      title: Language
    PartialArg:
      properties:
        boolValue:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Boolvalue
        jsonPath:
          anyOf:
            - type: string
            - type: 'null'
          title: Jsonpath
        nullValue:
          anyOf:
            - type: string
              const: NULL_VALUE
            - type: 'null'
          title: Nullvalue
        numberValue:
          anyOf:
            - type: number
            - type: 'null'
          title: Numbervalue
        stringValue:
          anyOf:
            - type: string
            - type: 'null'
          title: Stringvalue
        willContinue:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Willcontinue
      additionalProperties: false
      type: object
      title: PartialArg
    FunctionResponseScheduling:
      type: string
      enum:
        - SCHEDULING_UNSPECIFIED
        - SILENT
        - WHEN_IDLE
        - INTERRUPT
      title: FunctionResponseScheduling
    FunctionResponsePart:
      properties:
        inlineData:
          anyOf:
            - $ref: '#/components/schemas/FunctionResponseBlob'
            - type: 'null'
          description: Inline binary content with Base64-encoded data
        fileData:
          anyOf:
            - $ref: '#/components/schemas/FunctionResponseFileData'
            - type: 'null'
          description: File content referenced by URI
      additionalProperties: false
      type: object
      title: FunctionResponsePart
    ToolType:
      type: string
      enum:
        - TOOL_TYPE_UNSPECIFIED
        - GOOGLE_SEARCH_WEB
        - GOOGLE_SEARCH_IMAGE
        - URL_CONTEXT
        - GOOGLE_MAPS
        - FILE_SEARCH
      title: ToolType
    FunctionResponseBlob:
      properties:
        mimeType:
          anyOf:
            - type: string
            - type: 'null'
          title: Mimetype
          description: Content MIME type
        data:
          anyOf:
            - type: string
              contentEncoding: base64
              contentMediaType: application/octet-stream
            - type: 'null'
          title: Data
        displayName:
          anyOf:
            - type: string
            - type: 'null'
          title: Displayname
      additionalProperties: false
      type: object
      title: FunctionResponseBlob
    FunctionResponseFileData:
      properties:
        fileUri:
          anyOf:
            - type: string
            - type: 'null'
          title: Fileuri
          description: File URI
        mimeType:
          anyOf:
            - type: string
            - type: 'null'
          title: Mimetype
          description: Content MIME type
        displayName:
          anyOf:
            - type: string
            - type: 'null'
          title: Displayname
      additionalProperties: false
      type: object
      title: FunctionResponseFileData

````