Skip to content

Conversation

@Kking112
Copy link
Contributor

Created a Python SDK for OpenCode. I used openapi-python-client instead of stainless, as requested in #2266 .

I know that OpenCode normally does not take PR's for core features, but I wanted to do this for a few reasons and I figured I'd see what you guys think.

I expect there will be many changes to be made before merging is considered, so any feedback and constructive criticism is encouraged. I have done basic testing of the SDK but will likely do more in the coming days.

Kking112 and others added 18 commits September 22, 2025 16:25
…; add generation script and docs; verified by running generator and importing generated client
…erver or CLI; add flags and docs; verified generation via CLI path
…rts CLI/server sources and verified OpenAPI 3.1.1 compatibility
…wrapper (OpenCodeClient) with SSE and helpers; format post-generation; update docs and TODO
… and convenience methods (agents, projects, files, tools); mark Phase 4 progress in TODO
…rsing test, retry behavior; docs: update README examples; TODO: check off Phase 5 items
…), error-handling docs; extend tests incl. generated API call; mark Phase 5 items in TODO; format/lint
…d validate endpoints (path, project, SSE); mark Phase 5 fully complete in TODO.md
…nerate; add CI job to generate and test Python SDK; remove Stainless python target; update TODO
…ement publish script (build+twine), add dev deps (build, twine), add PyPI badge; update TODO
…e (config/sessions/files/streaming), generation, testing, publishing; wire mkdocs deps; update README with docs preview
…, ignore site/; verify no secrets; update TODO; tests passing
@rekram1-node
Copy link
Collaborator

@Kking112 sorry for such a delay, when you started this i wasn't sure what would be accepted but now Im responsible for reviewing prs and things, I would love to merge this can you outline the next steps we would need to get this shipped and can you make a brief summary of the changes?

@Kking112
Copy link
Contributor Author

@Kking112 sorry for such a delay, when you started this i wasn't sure what would be accepted but now Im responsible for reviewing prs and things, I would love to merge this can you outline the next steps we would need to get this shipped and can you make a brief summary of the changes?

Hey,

No Problem at all!

I will write up a summary of the changes plus any other information necessary for merging this in the next few days! I'll also resolve the package.json conflict that was auto detected.

Looking forward to seeing this merged once I'm done!

Thanks.

@rekram1-node
Copy link
Collaborator

amazing thanks!

@Kking112
Copy link
Contributor Author

Hey @rekram1-node , so here are the changes I made, along with what's (potentially) left to do before merging:

Summary of changes (feat/python_sdk)

• New Python SDK package: packages/sdk/python with uv-based dev setup (pyproject.toml), openapi-python-client.yaml, generator (scripts/generate.py), publish helper (scripts/publish.py), examples/, tests/, and full MkDocs docs (docs/, mkdocs.yml).
• SDK generation: CLI- and server-based OpenAPI fetch; post-gen injection of extras.py; auto-formatting (ruff imports + black); root package.json updated (generate includes Python; generate:python added).
• Wrapper: opencode_ai.extras.OpenCodeClient with auth headers, timeout, retries, convenience methods (projects, path, agents, sessions list, file status, tools/commands, config providers) and SSE (sync/async).
• Tests: unit + mock tests (httpx.MockTransport), generated-call smoke, and an integration test that starts the headless server and validates /path, /project, /event.
• CI: typecheck workflow gains python-sdk job (generate + uv sync + pytest). Release publishing workflow publish-python-sdk.yml builds and uploads to PyPI using PYPI_API_TOKEN; version set from tag.
• Docs: MkDocs site (Overview, Installation, Quickstart, Usage, Generation, Testing, Publishing); README updated with docs preview.
• Stainless: Python target removed from packages/sdk/stainless/stainless.yml.
• Cleanup: removed built docs site/ from VCS, added to .gitignore; confirmed no secrets in repo.

What’s left before merge

There shouldn't be much left before merging, at least not as far as I can tell. The main two:
• Merge documentation into the main opencode docs. (Let me know if you want me to do try to do this)
• Optional: broaden test coverage (async paths, more endpoints), and add Python lint job (ruff/black) in CI.

@Kking112
Copy link
Contributor Author

I just resolved the conflict in package.json, so it should be good to merge when you are ready @rekram1-node . Again, if you want me to change anything, let me know. Thanks!

@Kking112
Copy link
Contributor Author

There is an issue with the "publish-python-sdk.yml" file which caused the workflow to fail. I'm working on fixing it now, although I'm still pretty unexperienced with github actions/workflows so it may take a few tries, apologies in advance. Will continue trying until it's fixed.

…v python and handle missing GITHUB_REF_NAME; strip leading 'v' from tag
Kking112 and others added 3 commits October 28, 2025 11:22
…k to @opencode-ai/sdk; add pre-push install; add temporary workarounds in console-function/slack to unblock push
@Kking112
Copy link
Contributor Author

I'm going to keep trying to fix the workflows that are failing, but if someone who has more experience with github actions/workflows (or just CI/CD in general) wants to try to fix these final issue themselves, please feel free to do so, I would greatly appreciate it.

@rekram1-node
Copy link
Collaborator

im gonna disable / remove some of the actions for now, we will figure out how to publish it next once we have a pypi account setup

@rekram1-node rekram1-node merged commit 0e60f66 into sst:dev Oct 28, 2025
3 checks passed
@rekram1-node
Copy link
Collaborator

Thanks @Kking112

@hayblebenedict5-max
Copy link

G4MTpD-W0AAZfrN

@Kking112
Copy link
Contributor Author

G4MTpD-W0AAZfrN

?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants