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

# Execute an agent

> Run one agent with a prompt. Sync by default; `sync: false` returns a pointer to redeem later; `stream: true` streams OpenAI-shaped chunks.


## OpenAPI

```yaml openapi.json post /v1/agents/{id}/execute
openapi: 3.1.0
info:
  title: Ocean One API
  version: 2.1.0
servers:
  - url: https://api.plungeai.com
paths:
  /v1/agents/{id}/execute:
    post:
      summary: Execute an agent with a prompt (sync by default; sync:false returns a pointer)
      security:
        - ozkBearer: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                prompt:
                  type: string
                input:
                  type: string
                  description: Alias for prompt
                persona:
                  type: string
                provider:
                  type: string
                  description: Provider id (anthropic, openai, gemini, …); required alongside a pinned model
                model:
                  type: string
                maxTokens:
                  type: integer
                  description: "Max output tokens (alias: max_tokens)"
                max_tokens:
                  type: integer
                  description: Alias for maxTokens
                temperature:
                  type: number
                  description: Sampling temperature, forwarded to the provider
                top_p:
                  type: number
                  description: Nucleus sampling probability, forwarded to the provider
                reasoning_effort:
                  type: string
                  description: Reasoning-effort hint (e.g. low/medium/high) for reasoning models
                thinking_level:
                  type: string
                  description: Extended-thinking level hint for models that support it
                system:
                  type: string
                  description: System prompt / instructions for the run
                messages:
                  type: array
                  description: Prior chat messages ([{role, content}]) instead of a single prompt
                  items:
                    type: object
                sync:
                  type: boolean
                  default: true
                stream:
                  type: boolean
                  default: false
                  description: When true, the response is an OpenAI-shaped chat.completion.chunk SSE (see the 200 text/event-stream variant) instead of a JSON result. Ignored by the async pointer path.
                format:
                  type: string
                  enum:
                    - json
                    - yaml
                    - markdown
                    - text
                  description: "Response format override (precedence: this field → Accept header → mirror of the request Content-Type). Default json. yaml = the envelope with Markdown as block scalars; markdown = the same result the MCP plane renders; text = the bare result content. An unknown value → 400 invalid_format."
      responses:
        "200":
          description: 'Resolved result. Default (stream absent/false): a JSON result object. With stream:true: an OpenAI-shaped chat.completion.chunk SSE — one primer chunk carrying delta.role="assistant", then a delta.content chunk per provider token, then a final chunk with delta:{} and finish_reason "stop" (or "length" when the model was truncated at max_tokens), then a literal `data: [DONE]` line. usage is emitted on the final chunk only when the provider reports the prompt/completion split (often omitted for streamed runs). Comment keepalives (`: OCEAN PROCESSING`) may appear every ~15s while idle. Errors before the first byte are the normal JSON error envelopes below (not SSE); an error after the first byte is a single `data: {"error":{…}}` frame and the stream closes WITHOUT `[DONE]`. Response header X-Execution-Id carries the execution id for result redemption / polling. Response format negotiates via the `format` field, an Accept header (application/json, text/yaml, text/markdown, text/plain), or the request Content-Type mirror; default JSON.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  content:
                    type: string
                  workflow_id:
                    type: string
                  task_id:
                    type: string
                  request_id:
                    type: string
                required:
                  - content
            text/yaml:
              schema:
                type: string
            text/markdown:
              schema:
                type: string
            text/plain:
              schema:
                type: string
            text/event-stream:
              schema:
                type: string
              example: |+
                data: {"id":"chatcmpl-e2222ee13ea2499a95105245","object":"chat.completion.chunk","created":1788574344,"model":"llm-agent","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

                data: {"id":"chatcmpl-e2222ee13ea2499a95105245","object":"chat.completion.chunk","created":1788574344,"model":"llm-agent","choices":[{"index":0,"delta":{"content":"391"},"finish_reason":null}]}

                data: {"id":"chatcmpl-e2222ee13ea2499a95105245","object":"chat.completion.chunk","created":1788574344,"model":"llm-agent","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

                data: [DONE]

        "202":
          description: Accepted (async) — redeem via /v1/agents/results/{workflowId}/{taskId}
          content:
            application/json:
              schema:
                type: object
                properties:
                  workflow_id:
                    type: string
                  task_id:
                    type: string
                  request_id:
                    type: string
        "400":
          description: missing_prompt / invalid_format — format must be one of json, yaml, markdown, text
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "403":
          description: agent_not_active — the agent card is not status:active (refused pre-dispatch)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "404":
          description: unknown_agent — no such agent id in the registry (refused pre-dispatch)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "409":
          description: duplicate_execution_id — x-trace-id already used by an earlier run — send a fresh UUID
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "413":
          description: payload_too_large — body over 1 MiB (MAX_REQUEST_SIZE)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "422":
          description: invalid_params — needs_input (the agent named a missing/invalid input); unknown_model (pinned model absent/inactive in the catalog); empty_completion (the run completed but the model returned no visible content — raise max_tokens ≥ 64 or change the model)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "424":
          description: connection_required / credential_required — agent needs a connection or key
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "429":
          description: rate_limited — Retry-After header
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "502":
          description: engine_error / result_unavailable
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "503":
          description: agent_unavailable — agent temporarily down
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
components:
  schemas:
    Error:
      type: object
      description: Standard error envelope. Every error response also carries an `X-Error-Code` response header equal to error.code, so a client branches on the header regardless of the negotiated body format (json | yaml | markdown | text). When the request created an execution, the `X-Execution-Id` response header is also set. Errors follow the negotiated format like success bodies.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
          required:
            - code
            - message
          additionalProperties: true
      required:
        - error
  securitySchemes:
    ozkBearer:
      type: http
      scheme: bearer
      description: "ozk_ platform API key (Authorization: Bearer ozk_…)"
```
