We welcome bug reports, feature requests, minimal reproductions, and root-cause analysis through GitHub issues.
Pull requests are limited to repository collaborators. We do not accept pull requests from non-collaborators, including documentation or example changes. If you are not a collaborator, please open an issue instead of preparing a pull request. Include the affected version, expected and actual behavior, and a small, sanitized reproduction when applicable.
Report suspected security vulnerabilities privately as described in SECURITY.md, rather than in issues or pull requests.
The development and pull request instructions below are for maintainers and repository collaborators.
Before running any setup commands, review dependency origins, installation tooling, and the security requirements. Bootstrap and lint scripts can download Go, Homebrew, and direct or transitive dependencies.
To set up the repository, run:
$ ./scripts/bootstrap
$ ./scripts/lintThis will install all the required dependencies and build the SDK.
Contributors need Go 1.26 or later and
Node.js 14 or later. Homebrew can install both from
the repository's Brewfile; they can also be installed manually.
CI tests every supported Go release line with GOTOOLCHAIN=local, so
contributors should not rely on automatic toolchain downloads to satisfy the
repository's minimum version.
Look up the repository-relative path in the Castiron generated-file inventory. To report a bug, include the SDK version, affected call, and a small, sanitized reproduction.
- Incorrect API field. If the API schema gives a field the wrong type or marks it required incorrectly, fix the schema and regenerate the SDK.
- Incorrect generated code. If the schema is correct but the SDK exposes the wrong type or sends the wrong value, fix the generation configuration or compiler and regenerate. Verify the fix with a regression test that calls the public SDK.
- Handwritten helper or example. Keep SDK-specific extensions in handwritten files and test them directly. For instance, chatcompletion_helpers.go is handwritten. The generator also preserves lib/ and examples/.
Regeneration replaces owned files, including generated tests, docs, and workflows, and removes retired paths. Review the output and inventory together. Resolve ownership collisions before regenerating. Never hand-edit generated output or its inventory. Maintainers enforce this policy in code review.
- Never commit API keys, access tokens, Azure or AWS credentials, signing
keys,
.envfiles, or customer data. Read credentials from environment variables such asOPENAI_API_KEY; use synthetic values and payloads in examples, tests, and fixtures. Preferhttptestor the existing local mock server over requests to live services. - Redact all credential-bearing request and response headers and other
metadata, including
Authorization,Cookie,Set-Cookie,Api-Key,X-Api-Key, andX-Amz-Security-Token; credentials in URLs or query parameters; webhook secrets; and sensitive request or response bodies before logging, recording, forwarding, or disclosure. SDK error formatting methods return a status-only summary. Go's invalid-format diagnostics may bypass those methods and expose raw fields; use valid directives as documented in README.md.Error.DumpRequest,Error.DumpResponse,Error.RawJSON, and exported error fields still expose raw diagnostics that may include credentials, URLs, headers, or bodies; sanitize them before sharing or sending them to an untrusted sink. Preserve safe synthetic payloads and intentional public API error or debug diagnostics. - Review direct and transitive dependency changes in
go.modandgo.sumacross the root,examples,api_reference,internal/testdata/consumer, andtoolsmodules. Review newreplacedirectives, dependency origins, installation scripts, code generators, and source-based mock tooling before running them; preserve Go checksum verification and run the existing vulnerability checks. - Keep third-party GitHub Actions pinned to reviewed full commit SHAs, grant CI and publishing jobs only their required permissions, and isolate release credentials from untrusted pull requests or other untrusted code.
- Obtain SDK CODEOWNER review for changes involving authentication, webhook verification, base URLs, redirects, proxies, TLS, file paths or uploads, JSON or event-stream decoding, dependency installation, code generation, CI, or release tooling. Add focused public-entrypoint regression or security tests for executable behavior changes; use artifact-appropriate validation for docs, dependency, generated, CI, release, or policy-only changes.
- Report suspected vulnerabilities privately according to SECURITY.md. Do not open public issues, pull requests, or discussions about them.
All files in the examples/ directory are not modified by the generator and can be freely edited or added to.
# add an example to examples/<your-example>/main.go
package main
func main() {
// ...
}$ go run ./examples/<your-example>To use a local version of this library from source in another project, edit the go.mod with a replace
directive. This can be done through the CLI with the following:
$ go mod edit -replace github.com/openai/openai-go=/path/to/openai-goThe mock server uses the OpenAI Steady fork.
scripts/steady/manifest.json is the single source of dependency pins: the
Steady Git commit and source digest, plus the Deno version and runtime checksums. ./scripts/steady/install fetches that source, verifies the runtime,
and caches dependencies using the fork's frozen Deno lockfile. It requires
Git, Node.js, curl, unzip, and sha256sum or shasum. The installation supports
macOS and Linux on x64/ARM64, and Windows x64 through Git Bash.
./scripts/run-steady verifies the local source and runtime, then runs without
downloading dependencies. Pass a local OpenAPI specification path. To update
Steady, review the fork commit and run
node scripts/steady/update.cjs <full-commit-sha>. This updates the manifest
with the commit and its source digest; no launcher or test edits are needed.
Then run ./scripts/steady/install. Review the release checksums when changing Deno.
Run node scripts/steady/test.cjs to check the
installation, integrity checks, and mock-server lifecycle.
Most tests require you to set up a mock server against the OpenAPI spec to run the tests.
./scripts/bootstrap and ./scripts/mock install the pinned Steady source
and runtime with ./scripts/steady/install.
$ ./scripts/mock$ ./scripts/testTests that require multiple GiB of memory are opt-in. Keep them in
*_highmemory_test.go files with //go:build highmemory above the package
statement, separated by a blank line. Normal go test ./... and CI runs exclude
these files. Preserve the full payloads and assertions when moving a test.
Include high-memory tests explicitly on a machine with enough available RAM:
./scripts/test -tags=highmemoryThe script sets up the mock server and forwards the flag to go test ./....
To run just the large reconstruction test, which uses local fixtures:
go test -tags=highmemory -count=1 ./internal/websockettest \
-run '^TestResponsesAccumulatorReconstructedLargeResponse$'The large reconstruction test has measured peak memory usage above 6 GiB, so
leave additional room for the operating system and other processes. Keep smaller
reconstruction tests and the separate large WebSocket transport test in the
default suite. Run memory-heavy cases sequentially; use -p=1 to serialize
packages when enabling high-memory tests across multiple packages.
Tagged files are not compiled in default runs. When changing a high-memory test or the code it exercises, validate both the default and tagged test modes.
This library uses the standard go fmt command. Run it in each module that
contains Go source:
$ go fmt ./...
$ go -C examples fmt ./...
$ go -C internal/testdata/consumer fmt ./...The Go code quality policy describes the staged formatting and static-analysis rules for generated and handwritten code.