Skip to content

[question] API documentation #2168

Closed
Closed

Description

@Drinect

Good day to you!

I'm developing a Python SDK to interface with the OpenCode API as an alternative to the ClaudeCode SDK.

Context:

I've generated a Python client using OpenAPI Generator and your openapi json (fetched from 127.0.0.1:4096/doc)

For now, I'm focusing only on the session endpoints, as this is the minimum needed to get some code generated.

Issue/Question
I'm unclear about the expected flow between API endpoints, particularly regarding message handling.
Current behavior:

When calling session.chat({ id, ...chatInput }) (which in my Python client translates to POST: http://127.0.0.1:4096/session/ses_72eb63d80ffe11MuiSwJ3G3wD4/message), I receive an empty response
The response contains neither the model's response nor a message ID that could be used for polling

Expected behavior (based on SDK documentation):

The documentation indicates this endpoint "returns a message."
I expected either:

The model's response directly, OR
A message ID to poll for the response

Questions:

Is the empty response from the /message endpoint expected behavior?
Should I be polling the messages list endpoint (GET /session/{id}/messages) to retrieve new messages after posting?
What is the intended flow for:

Sending a message to the model
Receiving/retrieving the model's response

Some other endpoint I also find confusing, like:
What are the APP endpoints for? Does one need to initialize the app when setting up the server?

What's the use of the File endpoints? Are they for the TUI to provide file searching capabilities in the repo for the client who is potentially on another machine? Are there other use cases?

Is there additional API documentation available that describes the endpoint interaction patterns?

Environment

Generated client using OpenAPI Generator
Python client is generated with urllib3 (synchronous)
API endpoint: http://127.0.0.1:4096

Any clarification on the proper API flow would be greatly appreciated. Happy to provide additional details if needed.

Activity

  1. github-actions commented on Aug 22, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. rekram1-node commented on Aug 22, 2025

    @rekram1-node
    Contributor

    I think this endpoint was not properly documented, the spec should be fixed in next release

  3. rekram1-node commented on Aug 22, 2025

    @rekram1-node
    Contributor

    You will need to regen your sdk after that

  4. Drinect commented on Aug 25, 2025

    @Drinect
    Author

    Thanks! I’ll regenerate the SDK after the next release.

    While you’re updating the spec, could you also add OpenAPI tags to group endpoints? This lets generators produce namespaced clients (e.g., client.session.chat()) instead of flat names (client.session_chat()).
    Example: for POST /session/{id}/message, add "tags": ["session"] and use "operationId": "chat" (instead of "session.chat").

    Suggested tags: session, config, app, file, find, tui, event, auth.

    I suspect you created the OpenAPI spec by a generator. So I'm not sure if it's possible. But it would help me (and maybe others who try to generate clients for your API) a lot.

  5. rekram1-node commented on Aug 25, 2025

    @rekram1-node
    Contributor

    good idea

  6. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Contributor

    [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions