OpenCode icon

OpenCode

Interact with OpenCode Server API for AI coding assistant sessions

Message → Send

AI-generated

Summary

Send a message and receive a response from an OpenCode session, with optional session management and response formatting.

Inputs

  • sessionMode — Choose how to handle sessions. Use Existing Session for continuing conversations; Temporary Session to create a new session deleted after response.
  • sessionId (required) — Select a session for messaging. Required when sessionMode is 'existing'. Loaded from existing sessions via getSessions.
  • tempSessionTitle — Title for temporary sessions (for debugging purposes). Used when sessionMode is 'temporary'. Defaults to 'Temporary Chat Session'.
  • message (required) — The message to send. Rendered as-is with optional file references prepended as @filename.
  • model — Select a model (optional, uses default if not specified). Format: 'providerID::modelID' when splitting provider-specific models.
  • simpleResponse — Whether to return only the response text (true) or full metadata (false). Defaults to false.
  • referencedFiles — Select files to reference in the message (will be prepended as @filename). Files are joined with a newline before the message text.
  • options — Additional options for the request. Contains timeout, trimResponse, responseKey, agent, messageID, system, noReply, and tools.

Output shape

If simpleResponse is true: returns {{json: { [responseKey]: }, pairedItem: { item: ... }}}. If the response text is valid JSON, it is parsed and returned as-is. If simpleResponse is false: returns {{json: { messageId, sessionId, model, provider, tokens, cost, wasTemporarySession, [responseKey]: , parts: }, pairedItem: { item: ... }}}.

Sessions marked temporary are automatically deleted after the API call in a finally block. Existing sessions are reused. File references are prepended as '@filename' with a newline separator. Model strings containing '::' are split into {providerID, modelID} objects for the API payload. Tools JSON strings are parsed; invalid JSON is silently ignored. noReply is passed to the API payload but does not alter the send operation's response extraction behavior beyond that.

Links

Discussion