Python SDK #2659

Open
opened 2026-02-16 17:36:41 -05:00 by yindo · 21 comments
Owner

Originally created by @blissfolly on GitHub (Nov 7, 2025).

Originally assigned to: @rekram1-node on GitHub.

Have you published a Python SDK / Developer API package for version ≥ 1.0.39 please? Can you forward me a link to download this please if so.

Thanks, Mark

Originally created by @blissfolly on GitHub (Nov 7, 2025). Originally assigned to: @rekram1-node on GitHub. Have you published a Python SDK / Developer API package for version ≥ 1.0.39 please? Can you forward me a link to download this please if so. Thanks, Mark
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2025):

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

  • #2266: Feature request for Python SDK - This issue has the same request for a Python SDK and already has 10 comments with discussion about implementation using stainless and the publishing burden

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

@github-actions[bot] commented on GitHub (Nov 7, 2025): This issue might be a duplicate of existing issues. Please check: - #2266: Feature request for Python SDK - This issue has the same request for a Python SDK and already has 10 comments with discussion about implementation using stainless and the publishing burden Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Nov 7, 2025):

@blissfolly we do have one but I need to release it and write some CI to keep it up to date

it's in packages/sdk/python but it is a bit outdated

@rekram1-node commented on GitHub (Nov 7, 2025): @blissfolly we do have one but I need to release it and write some CI to keep it up to date it's in packages/sdk/python but it is a bit outdated
Author
Owner

@blissfolly commented on GitHub (Nov 7, 2025):

Thank you. Do you plan to update it or are you focussing on them user
interface?

Cheers,

Mark

On Fri, 7 Nov 2025 at 16:05, Aiden Cline @.***> wrote:

rekram1-node left a comment (sst/opencode#4031)
https://github.com/sst/opencode/issues/4031#issuecomment-3503405176

@blissfolly https://github.com/blissfolly we do have one but I need to
release it and write some CI to keep it up to date

it's in packages/sdk/python but it is a bit outdated


Reply to this email directly, view it on GitHub
https://github.com/sst/opencode/issues/4031#issuecomment-3503405176, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AYCQ5SEROQ6MNTGQOHEPE6D33S7MDAVCNFSM6AAAAACLNYLVV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMBTGQYDKMJXGY
.
You are receiving this because you were mentioned.Message ID:
@.***>

@blissfolly commented on GitHub (Nov 7, 2025): Thank you. Do you plan to update it or are you focussing on them user interface? Cheers, Mark On Fri, 7 Nov 2025 at 16:05, Aiden Cline ***@***.***> wrote: > *rekram1-node* left a comment (sst/opencode#4031) > <https://github.com/sst/opencode/issues/4031#issuecomment-3503405176> > > @blissfolly <https://github.com/blissfolly> we do have one but I need to > release it and write some CI to keep it up to date > > it's in packages/sdk/python but it is a bit outdated > > — > Reply to this email directly, view it on GitHub > <https://github.com/sst/opencode/issues/4031#issuecomment-3503405176>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/AYCQ5SEROQ6MNTGQOHEPE6D33S7MDAVCNFSM6AAAAACLNYLVV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMBTGQYDKMJXGY> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@rekram1-node commented on GitHub (Nov 7, 2025):

I think I can get it publishing soon

@rekram1-node commented on GitHub (Nov 7, 2025): I think I can get it publishing soon
Author
Owner

@blissfolly commented on GitHub (Nov 7, 2025):

Thank you fella, am assuming you’ll put any updates into the same
repository? To have a up to date python interface will be fabulous. Thanks
again.

On Fri, 7 Nov 2025 at 16:10, Aiden Cline @.***> wrote:

rekram1-node left a comment (sst/opencode#4031)
https://github.com/sst/opencode/issues/4031#issuecomment-3503432399

I think I can get it publishing soon


Reply to this email directly, view it on GitHub
https://github.com/sst/opencode/issues/4031#issuecomment-3503432399, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AYCQ5SCHGDODHZNZIWCDUPT33S76PAVCNFSM6AAAAACLNYLVV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMBTGQZTEMZZHE
.
You are receiving this because you were mentioned.Message ID:
@.***>

@blissfolly commented on GitHub (Nov 7, 2025): Thank you fella, am assuming you’ll put any updates into the same repository? To have a up to date python interface will be fabulous. Thanks again. On Fri, 7 Nov 2025 at 16:10, Aiden Cline ***@***.***> wrote: > *rekram1-node* left a comment (sst/opencode#4031) > <https://github.com/sst/opencode/issues/4031#issuecomment-3503432399> > > I think I can get it publishing soon > > — > Reply to this email directly, view it on GitHub > <https://github.com/sst/opencode/issues/4031#issuecomment-3503432399>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/AYCQ5SCHGDODHZNZIWCDUPT33S76PAVCNFSM6AAAAACLNYLVV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMBTGQZTEMZZHE> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@rekram1-node commented on GitHub (Nov 7, 2025):

Yes, in this repo

@rekram1-node commented on GitHub (Nov 7, 2025): Yes, in this repo
Author
Owner

@shreyansh073 commented on GitHub (Jan 6, 2026):

Hi, bumping this up. Would be great if there's a python sdk for this - I'm currently generating the pydantic interface from the config's json schema directly, and would need to manually update it everytime the schema changes.

This repo doesn't seem to be updated

@shreyansh073 commented on GitHub (Jan 6, 2026): Hi, bumping this up. Would be great if there's a python sdk for this - I'm currently generating the pydantic interface from the config's json schema directly, and would need to manually update it everytime the schema changes. [This repo](https://github.com/anomalyco/opencode-sdk-python?tab=readme-ov-file) doesn't seem to be updated
Author
Owner

@mrlubos commented on GitHub (Jan 12, 2026):

Tracking 🐍

@mrlubos commented on GitHub (Jan 12, 2026): Tracking 🐍
Author
Owner

@davidbernat commented on GitHub (Feb 3, 2026):

@shreyansh073 agreed that the opencode-sdk-python appears up to date re: @freedom07
My understanding is that the python code itself was generated from the OpenAPI scheme of the REST API itself automatically*.
I did several searches online at GitHub and search engines, and cannot find even one package that contains a requirements.txt file with opencode-sdk-python. I am further exploring with a deep research agentic AI that I have and finding nothing. From what I can see from these results it is most probably OpenCode never supported a Python SDK. Which, again, is challenging to understand. I have communicated opinions regarding typed languages and projects such as these for many years (c.f. 2019) and this simply cannot be resolved with my expectations any longer. Looking forward to moving on. Eventually.

Does anyone have tutorials on the basic json-line streaming examples of the REST API at a quick disposal? I am late for a thing.
PS @freedom07 if you need anything for a PR that my dummy dummy dummy mind can help feel free to comment along here.

@davidbernat commented on GitHub (Feb 3, 2026): @shreyansh073 agreed that the `opencode-sdk-python` appears up to date re: @freedom07 My understanding is that the python code itself was generated from the OpenAPI scheme of the REST API itself automatically*. I did several searches online at GitHub and search engines, and cannot find even one package that contains a `requirements.txt file` with `opencode-sdk-python`. I am further exploring with a deep research agentic AI that I have and finding nothing. From what I can see from these results it is most probably OpenCode never supported a Python SDK. Which, again, is challenging to understand. I have communicated opinions regarding typed languages and projects such as these for many years (c.f. 2019) and this simply cannot be resolved with my expectations any longer. Looking forward to moving on. Eventually. Does anyone have tutorials on the basic json-line streaming examples of the REST API at a quick disposal? I am late for a thing. PS @freedom07 if you need anything for a PR that my dummy dummy dummy mind can help feel free to comment along here.
Author
Owner

@davidbernat commented on GitHub (Feb 4, 2026):

Can confirm: OpenCode does not support a Python SDK.

  1. the documentation does not exist.
  2. github returns zero repositories with opencode-sdk-python in requirements.txt
  3. its own chat agent returns one file with a example which is out of date and runs a trivial use case.
  4. its own code agents create malformed sample code
  5. basic utilities such as client.config.get() fail to return all active agents, including OpenCode's own.
  6. (The REST API also commits these errors?)
  7. basic utilities such as client.session.create() which are required for all subsequent operations fail with opaque "malformed JSON request" before even compiling a request to send to the server. This method is the session initiation required to get a session_id to begin a new session through .chat(). This happens in both sync and async clients in opencode-sdk-python.
  8. (The REST API returns session_id as expected)
  9. The local coffeeshop is gifting strawberry shortcake today, which is nice.
  10. (Instead of its usual burnt ends of the banana bread. Yum.)

Tracking the issue, and building a simple REST API client on our own. Thanks.

Image
@davidbernat commented on GitHub (Feb 4, 2026): Can confirm: OpenCode does not support a Python SDK. 1. the documentation does not exist. 2. github returns zero repositories with opencode-sdk-python in requirements.txt 3. its own chat agent returns one file with a example which is out of date and runs a trivial use case. 4. its own code agents create malformed sample code 5. basic utilities such as `client.config.get()` fail to return all active agents, including OpenCode's own. 6. (The REST API also commits these errors?) 7. basic utilities such as `client.session.create()` which are required for all subsequent operations fail with opaque "malformed JSON request" before even compiling a request to send to the server. This method is the session initiation required to get a session_id to begin a new session through .chat(). This happens in both sync and async clients in `opencode-sdk-python`. 8. (The REST API returns session_id as expected) 9. The local coffeeshop is gifting strawberry shortcake today, which is nice. 10. (Instead of its usual burnt ends of the banana bread. Yum.) Tracking the issue, and building a simple REST API client on our own. Thanks. <img width="691" height="142" alt="Image" src="https://github.com/user-attachments/assets/7d41b611-ea42-4d39-8b50-a9824f2613c2" />
Author
Owner

@R44VC0RP commented on GitHub (Feb 4, 2026):

We are working on a Python SDK with another provider, going to close this as it is planned internally.

@R44VC0RP commented on GitHub (Feb 4, 2026): We are working on a Python SDK with another provider, going to close this as it is planned internally.
Author
Owner

@freedom07 commented on GitHub (Feb 4, 2026):

That’s great news. Looking forward to being able to use the Python SDK soon!

Separately, sharing this with @davidbernat for reference:
I previously uploaded the package to TestPyPI and ran a quick end-to-end test.
You can install the test package with the command below and then try running the code that follows:

pip install --extra-index-url https://test.pypi.org/simple/ opencode-sdk==0.1.0

import asyncio
from opencode_sdk import create_opencode_async
from opencode_sdk.types import Config

async def main():
    config: Config = {
        # Set default model (format: "provider/model")
        "model": "openai/gpt-5.1",

        # Configure logging
        "logLevel": "INFO",

        # Enable/disable specific tools (all lowercase)
        "tools": {
            "bash": True,
            "read": True,
            "write": True,
            "edit": True,
            "glob": True,
            "grep": True,
            "list": True,
            "webfetch": True,
            "todowrite": True,
            "todoread": True,
            "question": True,
            "skill": True,
            "patch": True,
        },

        # Add custom commands (slash commands)
        "command": {
            "review": {
                "description": "Review the code and suggest improvements",
                "template": "Review the following code and suggest improvements:\n$ARGUMENTS",
                "agent": "default",
            },
            "test": {
                "description": "Generate tests for the code",
                "template": "Generate comprehensive tests for:\n$ARGUMENTS",
                "model": "openai/gpt-5.1",
            },
        },

        # Configure custom agents
        "agent": {
            "architect": {
                "description": "Senior software architect for system design",
                "model": "openai/gpt-5.1",
                "temperature": 0.7,
                "prompt": "You are a senior software architect. Focus on scalability, maintainability, and best practices.",
                "tools": {
                    "read": True,
                    "glob": True,
                    "grep": True,
                    "write": False,  # Read-only agent
                },
            },
            "reviewer": {
                "description": "Code reviewer focused on quality",
                "model": "openai/gpt-5.1",
                "prompt": "You are a code reviewer. Focus on bugs, security issues, and code quality.",
                "maxSteps": 10,
            },
        },

        # Add MCP servers
        "mcp": {
            # Local MCP server - shadcn UI components
            "shadcn": {
                "type": "local",
                "command": ["npx", "shadcn@latest", "mcp"],
                "enabled": True,
            },
            # Local MCP server - Mermaid diagram generator
            "mcp-mermaid": {
                "type": "local",
                "command": ["npx", "-y", "mcp-mermaid"],
                "enabled": True,
            },
            # Remote MCP server - OpenAI Developer Docs
            "openaiDeveloperDocs": {
                "type": "remote",
                "url": "https://developers.openai.com/mcp",
                "enabled": True,
            },
            # Remote MCP server with OAuth - Sentry
            "sentry": {
                "type": "remote",
                "url": "https://mcp.sentry.dev/mcp",
                "oauth": {},  # Auto OAuth
            },
            # Remote MCP server - Context7 (docs search)
            "context7": {
                "type": "remote",
                "url": "https://mcp.context7.com/mcp",
            },
        },

        # Add plugins
        "plugin": [],

        # Custom instructions
        "instructions": [
            "Always use TypeScript for new files",
            "Follow the existing code style",
            "Write comprehensive tests",
        ],
    }

    opencode = await create_opencode_async(config=config)

    client = opencode.client

    # Use custom agent
    session = await client.session.create_async(title="Architecture Review")
    print(session)
    if session.ok:
        response = await client.session.prompt_async(
            session.data["id"],
            parts=[{"type": "text", "text": "Hello world!"}],
        )
        print(response.data)

asyncio.run(main())
@freedom07 commented on GitHub (Feb 4, 2026): That’s great news. Looking forward to being able to use the Python SDK soon! Separately, sharing this with @davidbernat for reference: I previously uploaded the package to TestPyPI and ran a quick end-to-end test. You can install the test package with the command below and then try running the code that follows: `pip install --extra-index-url https://test.pypi.org/simple/ opencode-sdk==0.1.0` ```python import asyncio from opencode_sdk import create_opencode_async from opencode_sdk.types import Config async def main(): config: Config = { # Set default model (format: "provider/model") "model": "openai/gpt-5.1", # Configure logging "logLevel": "INFO", # Enable/disable specific tools (all lowercase) "tools": { "bash": True, "read": True, "write": True, "edit": True, "glob": True, "grep": True, "list": True, "webfetch": True, "todowrite": True, "todoread": True, "question": True, "skill": True, "patch": True, }, # Add custom commands (slash commands) "command": { "review": { "description": "Review the code and suggest improvements", "template": "Review the following code and suggest improvements:\n$ARGUMENTS", "agent": "default", }, "test": { "description": "Generate tests for the code", "template": "Generate comprehensive tests for:\n$ARGUMENTS", "model": "openai/gpt-5.1", }, }, # Configure custom agents "agent": { "architect": { "description": "Senior software architect for system design", "model": "openai/gpt-5.1", "temperature": 0.7, "prompt": "You are a senior software architect. Focus on scalability, maintainability, and best practices.", "tools": { "read": True, "glob": True, "grep": True, "write": False, # Read-only agent }, }, "reviewer": { "description": "Code reviewer focused on quality", "model": "openai/gpt-5.1", "prompt": "You are a code reviewer. Focus on bugs, security issues, and code quality.", "maxSteps": 10, }, }, # Add MCP servers "mcp": { # Local MCP server - shadcn UI components "shadcn": { "type": "local", "command": ["npx", "shadcn@latest", "mcp"], "enabled": True, }, # Local MCP server - Mermaid diagram generator "mcp-mermaid": { "type": "local", "command": ["npx", "-y", "mcp-mermaid"], "enabled": True, }, # Remote MCP server - OpenAI Developer Docs "openaiDeveloperDocs": { "type": "remote", "url": "https://developers.openai.com/mcp", "enabled": True, }, # Remote MCP server with OAuth - Sentry "sentry": { "type": "remote", "url": "https://mcp.sentry.dev/mcp", "oauth": {}, # Auto OAuth }, # Remote MCP server - Context7 (docs search) "context7": { "type": "remote", "url": "https://mcp.context7.com/mcp", }, }, # Add plugins "plugin": [], # Custom instructions "instructions": [ "Always use TypeScript for new files", "Follow the existing code style", "Write comprehensive tests", ], } opencode = await create_opencode_async(config=config) client = opencode.client # Use custom agent session = await client.session.create_async(title="Architecture Review") print(session) if session.ok: response = await client.session.prompt_async( session.data["id"], parts=[{"type": "text", "text": "Hello world!"}], ) print(response.data) asyncio.run(main()) ```
Author
Owner

@freedom07 commented on GitHub (Feb 4, 2026):

@R44VC0RP If possible, could you share a bit more detail on which external provider you’re working with and roughly how far along the Python SDK implementation is?

@freedom07 commented on GitHub (Feb 4, 2026): @R44VC0RP If possible, could you share a bit more detail on which external provider you’re working with and roughly how far along the Python SDK implementation is?
Author
Owner

@davidbernat commented on GitHub (Feb 5, 2026):

Boys, this is, quiet possibly one ofthe weridedst update threads of opencoroe I have read yet, and for a tool as foundational as an SDK for Python?

  1. the ticket was closed. why?
  2. the issue is at best "marked as planned"
  3. @R44VC0RP does not have any opencode association on his profile just "3D printer"
  4. @freedom07 previously suggested his domain was the Python SDK, just one day ago.
  5. @freedom07 and @R44VC0RP are not in contact with each other, certainly not internally
  6. @freedom07 posts "Great News!" but does... nothing more than what I did about the config.
  7. @freedom07 did not address the session.create() issue which is required for all fresh interactions

What am we look at with this company invested in by Hoffman & YC?

@davidbernat commented on GitHub (Feb 5, 2026): Boys, this is, quiet possibly one ofthe weridedst update threads of opencoroe I have read yet, and for a tool as foundational as an SDK for Python? 1. the ticket was closed. why? 2. the issue is **at best** "marked as planned" 3. @R44VC0RP does not have any opencode association on his profile just "3D printer" 4. @freedom07 previously suggested his domain was the Python SDK, just one day ago. 5. @freedom07 and @R44VC0RP are not in contact with each other, certainly not internally 6. @freedom07 posts "Great News!" but does... nothing more than what I did about the config. 7. @freedom07 did not address the `session.create()` issue which is **required** for all fresh interactions What am we look at with this company invested in by Hoffman & YC?
Author
Owner

@davidbernat commented on GitHub (Feb 6, 2026):

Folks, for those who arrive here via search engine: starlight.ai created a rudimentary functional Python SDK + CLI interface for basic use cases of chat (text+files), authentication (username/password), session creation/listing (upon new), and agent/provider setting. The functionality within covers 99% of the basic first use cases of any application you want to use with a [local] operating opencode serve module (i.e., opencode local at scale). Keep in mind that opencode serve needs to be launched from its repository directory c.f. opencode.json (so, if you have a coder setup and researcher setup you may have two separate repositories), and as such are likely to have two or three opencode serve running at any one time on different ports. This is a living document and will update as I develop user cases; feel free to reach out via email if you have questions or problems. It was no skin to get this up and running for Friday. I took half-coded solutions run through an auto-coder and peer-reviewed through sipping two nips of kraken rum over ninety minutes. Please enjoy yourselves. Let me know what you need.

https://gist.github.com/davidbernat/95d03b06fdcbbe37cdddf110b4ed0c9f

@davidbernat commented on GitHub (Feb 6, 2026): Folks, for those who arrive here via search engine: starlight.ai created a rudimentary functional Python SDK + CLI interface for basic use cases of chat (text+files), authentication (username/password), session creation/listing (upon new), and agent/provider setting. The functionality within covers 99% of the basic first use cases of any application you want to use with a [local] operating `opencode serve` module (i.e., opencode local at scale). Keep in mind that opencode serve needs to be launched from its repository directory c.f. opencode.json (so, if you have a coder setup and researcher setup you may have two separate repositories), and as such are likely to have two or three `opencode serve` running at any one time on different ports. This is a living document and will update as I develop user cases; feel free to reach out via email if you have questions or problems. It was no skin to get this up and running for Friday. I took half-coded solutions run through an auto-coder and peer-reviewed through sipping two nips of kraken rum over ninety minutes. Please enjoy yourselves. Let me know what you need. https://gist.github.com/davidbernat/95d03b06fdcbbe37cdddf110b4ed0c9f
Author
Owner

@R44VC0RP commented on GitHub (Feb 6, 2026):

Reopening this to allow for discussion, we are having a Python SDK generated by the folks at Hey API. Unsure on timeline just yet, but will provide updates when I get them.

@R44VC0RP commented on GitHub (Feb 6, 2026): Reopening this to allow for discussion, we are having a Python SDK generated by the folks at Hey API. Unsure on timeline just yet, but will provide updates when I get them.
Author
Owner

@davidbernat commented on GitHub (Feb 6, 2026):

Guys, charitably, we're moving on. We're already mid-email to Paul Graham. It is an API, the one I posted works for what 99% of users need, and what breaks from being untested is a junior-level fix. We do not need "code word is correct" providers for an API generation, no matter how many times Elon Musk posts "ring stains" by his bedside or whatever else you all & Hoffman did.

Seriously. We know who we are. Hey API can pass on the offer.

@davidbernat commented on GitHub (Feb 6, 2026): Guys, charitably, we're moving on. We're already mid-email to Paul Graham. It is an API, the one I posted works for what 99% of users need, and what breaks from being untested is a junior-level fix. We do not need "code word is correct" providers for an API generation, no matter how many times Elon Musk posts "ring stains" by his bedside or whatever else you all & Hoffman did. Seriously. We know who we are. Hey API can pass on the offer.
Author
Owner

@vxnuaj commented on GitHub (Feb 12, 2026):

I still want the SDK. Tell Hey API to continue doing their job.

@vxnuaj commented on GitHub (Feb 12, 2026): I still want the SDK. Tell Hey API to continue doing their job.
Author
Owner

@mrlubos commented on GitHub (Feb 12, 2026):

@vxnuaj don't worry, it's coming 🤝

@mrlubos commented on GitHub (Feb 12, 2026): @vxnuaj don't worry, it's coming 🤝
Author
Owner

@vxnuaj commented on GitHub (Feb 12, 2026):

cool cool. curious if there's a rough timeline?

@vxnuaj commented on GitHub (Feb 12, 2026): cool cool. curious if there's a rough timeline?
Author
Owner

@davidbernat commented on GitHub (Feb 12, 2026):

I found that opencode serve routinely failed even on REST API calls. What exactly is the diligence on this company API?
We found serious problems getting answers on logs, exports, and subagents.
Just like this REST API, we built our own solution, and found that an enclosed component of opencode yet again failed.

@mrlubos What timeline is OpenCode promising us on a functioning, tested SDK framework, Python or otherwise?

@davidbernat commented on GitHub (Feb 12, 2026): I found that `opencode serve` routinely failed even on REST API calls. What exactly is the diligence on this company API? We found serious problems getting answers on logs, exports, and subagents. Just like this REST API, we built our own solution, and found that an enclosed component of opencode yet again failed. @mrlubos What timeline is OpenCode promising us on a functioning, tested SDK framework, Python or otherwise?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2659