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

# Create Task For Agent With Stream

> Create and execute a task for the specified agent with real-time SSE stream.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/agents/{agent_id}/tasks/
openapi: 3.1.0
info:
  description: >-
    Modular and extensible framework for building AI agents. This API requires
    JWT Bearer token authentication for most endpoints. Include your JWT token
    in the Authorization header. Public endpoints include /, /health, /docs,
    /redoc, and /openapi.json.
  title: AgentArea API
  version: 0.1.0
servers: []
security:
  - bearer: []
paths:
  /v1/agents/{agent_id}/tasks/:
    post:
      tags:
        - v1
        - protected
        - agent-tasks
      summary: Create Task For Agent With Stream
      description: >-
        Create and execute a task for the specified agent with real-time SSE
        stream.
      operationId: create_task_for_agent_with_stream_v1_agents__agent_id__tasks__post
      parameters:
        - in: path
          name: agent_id
          required: true
          schema:
            format: uuid
            title: Agent Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskCreate'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema: {}
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
      security:
        - HTTPBearer: []
components:
  schemas:
    TaskCreate:
      properties:
        attachments:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Attachments
        description:
          title: Description
          type: string
        execution:
          anyOf:
            - $ref: '#/components/schemas/RunExecutionConfig'
            - type: 'null'
        parameters:
          additionalProperties: true
          title: Parameters
          type: object
        project_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Project Id
        requires_human_approval:
          anyOf:
            - type: boolean
            - type: 'null'
          default: false
          title: Requires Human Approval
        task_policy:
          anyOf:
            - $ref: '#/components/schemas/PolicyDocument'
            - type: 'null'
      required:
        - description
      title: TaskCreate
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    RunExecutionConfig:
      additionalProperties: false
      description: Caller-requested execution ceiling; governance may only tighten it.
      properties:
        max_model_turns:
          description: Maximum LLM/model turns requested for this run.
          exclusiveMinimum: 0
          title: Max Model Turns
          type: integer
      required:
        - max_model_turns
      title: RunExecutionConfig
      type: object
    PolicyDocument:
      additionalProperties: false
      description: Source policy document stored per scope.
      properties:
        approval:
          anyOf:
            - $ref: '#/components/schemas/ApprovalPolicy'
            - type: 'null'
        budget:
          anyOf:
            - $ref: '#/components/schemas/BudgetPolicy-Input'
            - type: 'null'
        content_safety:
          anyOf:
            - $ref: '#/components/schemas/ContentSafetyPolicy'
            - type: 'null'
        execution:
          anyOf:
            - $ref: '#/components/schemas/ExecutionLimitsPolicy'
            - type: 'null'
        tokens:
          anyOf:
            - $ref: '#/components/schemas/TokenPolicy'
            - type: 'null'
        tools:
          anyOf:
            - $ref: '#/components/schemas/ToolsPolicy'
            - type: 'null'
      title: PolicyDocument
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
    ApprovalPolicy:
      additionalProperties: false
      description: Human approval and escalation requirements.
      properties:
        approvers:
          items:
            type: string
          title: Approvers
          type: array
        approvers_by_tool:
          additionalProperties:
            items:
              type: string
            type: array
          title: Approvers By Tool
          type: object
        escalation_rules:
          items:
            type: string
          title: Escalation Rules
          type: array
        requires_human_approval:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Requires Human Approval
      title: ApprovalPolicy
      type: object
    BudgetPolicy-Input:
      additionalProperties: false
      description: Budget-related ceilings.
      properties:
        monthly_spend_cap_usd:
          anyOf:
            - anyOf:
                - type: number
                - pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
                  type: string
              ge: '0'
            - type: 'null'
          title: Monthly Spend Cap Usd
        run_budget_usd:
          anyOf:
            - anyOf:
                - type: number
                - pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
                  type: string
              gt: '0'
            - type: 'null'
          title: Run Budget Usd
        service_budget_usd:
          anyOf:
            - anyOf:
                - type: number
                - pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
                  type: string
              gt: '0'
            - type: 'null'
          title: Service Budget Usd
      title: BudgetPolicy
      type: object
    ContentSafetyPolicy:
      additionalProperties: false
      description: Content-safety governance controls.
      properties:
        output_sanitizer_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Output Sanitizer Enabled
        prompt_injection_detection_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Prompt Injection Detection Enabled
      title: ContentSafetyPolicy
      type: object
    ExecutionLimitsPolicy:
      additionalProperties: false
      description: Ceilings for the agent loop and tool execution.
      properties:
        max_model_turns:
          anyOf:
            - exclusiveMinimum: 0
              type: integer
            - type: 'null'
          title: Max Model Turns
        max_tool_calls_per_turn:
          anyOf:
            - exclusiveMinimum: 0
              type: integer
            - type: 'null'
          title: Max Tool Calls Per Turn
        max_tool_calls_total:
          anyOf:
            - exclusiveMinimum: 0
              type: integer
            - type: 'null'
          title: Max Tool Calls Total
      title: ExecutionLimitsPolicy
      type: object
    TokenPolicy:
      additionalProperties: false
      description: Token-related ceilings.
      properties:
        max_tokens:
          anyOf:
            - exclusiveMinimum: 0
              type: integer
            - type: 'null'
          title: Max Tokens
        max_tokens_per_call:
          anyOf:
            - exclusiveMinimum: 0
              type: integer
            - type: 'null'
          title: Max Tokens Per Call
      title: TokenPolicy
      type: object
    ToolsPolicy:
      additionalProperties: false
      description: MCP tool capability restrictions.
      properties:
        allowed:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Allowed
        denied:
          items:
            type: string
          title: Denied
          type: array
      title: ToolsPolicy
      type: object
  securitySchemes:
    bearer:
      bearerFormat: JWT
      description: JWT Bearer token for authentication
      scheme: bearer
      type: http
    HTTPBearer:
      scheme: bearer
      type: http

````