Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ jobs:
github.repository == 'stainless-sdks/sapient-go' &&
(github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Get GitHub OIDC Token
if: |-
github.repository == 'stainless-sdks/sapient-go' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: core.setOutput('github_token', await core.getIDToken());

Expand All @@ -53,10 +53,10 @@ jobs:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup go
uses: actions/setup-go@v5
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: ./go.mod

Expand All @@ -68,10 +68,10 @@ jobs:
runs-on: ${{ github.repository == 'stainless-sdks/sapient-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup go
uses: actions/setup-go@v5
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version-file: ./go.mod

Expand Down
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.1.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 17
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sapient/sapient-908ede43a8944686476822ee14a7f1b1ae3999071a43582a6f88e5d4bff26b33.yml
openapi_spec_hash: d786bf9a6956b2e85340b6869646ee38
config_hash: ab4e633d60f3a8815964154998be703c
configured_endpoints: 34
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sapient/sapient-19772e79be7e030ebf8bd823aae76ff7e366c8f873aab056487dcc912ea5a6b4.yml
openapi_spec_hash: 92ead540a4d8d32f4411acf9de7fba21
config_hash: 67f1164874b1569a9845b46e7bfcc132
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

## 0.1.0 (2026-05-15)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/usesapient/go-sdk/compare/v0.0.1...v0.1.0)

### Features

* **api:** api update ([81040ca](https://github.com/usesapient/go-sdk/commit/81040cae143638e659bd7f46e915834389621b73))
* **api:** manual updates ([9006fc3](https://github.com/usesapient/go-sdk/commit/9006fc392d874ccb73467b5af2c8a604b137264d))
* **api:** manual updates ([1244e4f](https://github.com/usesapient/go-sdk/commit/1244e4fa9f72055fe47d674631447eecbd6de491))
* **client:** optimize json encoder for internal types ([c4a2fe9](https://github.com/usesapient/go-sdk/commit/c4a2fe9b93fcbd3a913cfd6d1063629d5151967d))
* Update Sapient public OpenAPI spec ([08e2481](https://github.com/usesapient/go-sdk/commit/08e2481a51e0c9078c6116ec07a2808a97d854f2))


### Bug Fixes

* **go:** avoid panic when http.DefaultTransport is wrapped ([2e82dd9](https://github.com/usesapient/go-sdk/commit/2e82dd9138032133a11d34e1aa61fd3ac76b2c65))


### Chores

* configure new SDK language ([7e6c8d5](https://github.com/usesapient/go-sdk/commit/7e6c8d56898948fc5d8f4c96122d67a6fd9cae64))
* redact api-key headers in debug logs ([70c3559](https://github.com/usesapient/go-sdk/commit/70c3559c6f6ee137cbae449697f3f165d4e3b610))
* update SDK settings ([aaa249d](https://github.com/usesapient/go-sdk/commit/aaa249d20e8fb643d66f48bf567af669ded55b14))
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ To use a local version of this library from source in another project, edit the
directive. This can be done through the CLI with the following:

```sh
$ go mod edit -replace github.com/stainless-sdks/sapient-go=/path/to/sapient-go
$ go mod edit -replace github.com/usesapient/go-sdk=/path/to/go-sdk
```

## Running tests
Expand Down
60 changes: 34 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,37 @@

<!-- x-release-please-start-version -->

<a href="https://pkg.go.dev/github.com/stainless-sdks/sapient-go"><img src="https://pkg.go.dev/badge/github.com/stainless-sdks/sapient-go.svg" alt="Go Reference"></a>
<a href="https://pkg.go.dev/github.com/usesapient/go-sdk"><img src="https://pkg.go.dev/badge/github.com/usesapient/go-sdk.svg" alt="Go Reference"></a>

<!-- x-release-please-end -->

The Sapient Go library provides convenient access to the Sapient REST API
The Sapient Go library provides convenient access to the [Sapient REST API](https://docs.usesapient.com)
from applications written in Go.

It is generated with [Stainless](https://www.stainless.com/).

## Installation

<!-- x-release-please-start-version -->

```go
import (
"github.com/stainless-sdks/sapient-go" // imported as sapient
"github.com/usesapient/go-sdk" // imported as githubcomusesapientgosdk
)
```

<!-- x-release-please-end -->

Or to pin the version:

<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/stainless-sdks/sapient-go@v0.0.1'
go get -u 'github.com/usesapient/go-sdk@v0.1.0'
```

<!-- x-release-please-end -->

## Requirements

This library requires Go 1.22+.
Expand All @@ -40,12 +48,12 @@ import (
"context"
"fmt"

"github.com/stainless-sdks/sapient-go"
"github.com/stainless-sdks/sapient-go/option"
"github.com/usesapient/go-sdk"
"github.com/usesapient/go-sdk/option"
)

func main() {
client := sapient.NewClient(
client := githubcomusesapientgosdk.NewClient(
option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("SAPIENT_API_KEY")
)
status, err := client.Status.Get(context.TODO())
Expand All @@ -59,31 +67,31 @@ func main() {

### Request fields

The sapient library uses the [`omitzero`](https://tip.golang.org/doc/go1.24#encodingjsonpkgencodingjson)
The githubcomusesapientgosdk library uses the [`omitzero`](https://tip.golang.org/doc/go1.24#encodingjsonpkgencodingjson)
semantics from the Go 1.24+ `encoding/json` release for request fields.

Required primitive fields (`int64`, `string`, etc.) feature the tag <code>\`api:"required"\`</code>. These
fields are always serialized, even their zero values.

Optional primitive types are wrapped in a `param.Opt[T]`. These fields can be set with the provided constructors, `sapient.String(string)`, `sapient.Int(int64)`, etc.
Optional primitive types are wrapped in a `param.Opt[T]`. These fields can be set with the provided constructors, `githubcomusesapientgosdk.String(string)`, `githubcomusesapientgosdk.Int(int64)`, etc.

Any `param.Opt[T]`, map, slice, struct or string enum uses the
tag <code>\`json:"...,omitzero"\`</code>. Its zero value is considered omitted.

The `param.IsOmitted(any)` function can confirm the presence of any `omitzero` field.

```go
p := sapient.ExampleParams{
ID: "id_xxx", // required property
Name: sapient.String("..."), // optional property
p := githubcomusesapientgosdk.ExampleParams{
ID: "id_xxx", // required property
Name: githubcomusesapientgosdk.String("..."), // optional property

Point: sapient.Point{
X: 0, // required field will serialize as 0
Y: sapient.Int(1), // optional field will serialize as 1
Point: githubcomusesapientgosdk.Point{
X: 0, // required field will serialize as 0
Y: githubcomusesapientgosdk.Int(1), // optional field will serialize as 1
// ... omitted non-required fields will not be serialized
},

Origin: sapient.Origin{}, // the zero value of [Origin] is considered omitted
Origin: githubcomusesapientgosdk.Origin{}, // the zero value of [Origin] is considered omitted
}
```

Expand Down Expand Up @@ -112,7 +120,7 @@ p.SetExtraFields(map[string]any{
})

// Send a number instead of an object
custom := param.Override[sapient.FooParams](12)
custom := param.Override[githubcomusesapientgosdk.FooParams](12)
```

### Request unions
Expand Down Expand Up @@ -253,7 +261,7 @@ This library uses the functional options pattern. Functions defined in the
requests. For example:

```go
client := sapient.NewClient(
client := githubcomusesapientgosdk.NewClient(
// Adds a header to every request made by the client
option.WithHeader("X-Some-Header", "custom_header_info"),
)
Expand All @@ -268,7 +276,7 @@ client.Status.Get(context.TODO(), ...,

The request option `option.WithDebugLog(nil)` may be helpful while debugging.

See the [full list of request options](https://pkg.go.dev/github.com/stainless-sdks/sapient-go/option).
See the [full list of request options](https://pkg.go.dev/github.com/usesapient/go-sdk/option).

### Pagination

Expand All @@ -282,7 +290,7 @@ with additional helper methods like `.GetNextPage()`, e.g.:
### Errors

When the API returns a non-success status code, we return an error with type
`*sapient.Error`. This contains the `StatusCode`, `*http.Request`, and
`*githubcomusesapientgosdk.Error`. This contains the `StatusCode`, `*http.Request`, and
`*http.Response` values of the request, as well as the JSON of the error body
(much like other response objects in the SDK).

Expand All @@ -291,7 +299,7 @@ To handle errors, we recommend that you use the `errors.As` pattern:
```go
_, err := client.Status.Get(context.TODO())
if err != nil {
var apierr *sapient.Error
var apierr *githubcomusesapientgosdk.Error
if errors.As(err, &apierr) {
println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request
println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
Expand Down Expand Up @@ -331,7 +339,7 @@ The file name and content-type can be customized by implementing `Name() string`
string` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a
file returned by `os.Open` will be sent with the file name on disk.

We also provide a helper `sapient.File(reader io.Reader, filename string, contentType string)`
We also provide a helper `githubcomusesapientgosdk.File(reader io.Reader, filename string, contentType string)`
which can be used to wrap any `io.Reader` with the appropriate file name and content type.

### Retries
Expand All @@ -344,7 +352,7 @@ You can use the `WithMaxRetries` option to configure or disable this:

```go
// Configure the default for all requests:
client := sapient.NewClient(
client := githubcomusesapientgosdk.NewClient(
option.WithMaxRetries(0), // default is 2
)

Expand Down Expand Up @@ -405,7 +413,7 @@ or the `option.WithJSONSet()` methods.
params := FooNewParams{
ID: "id_xxxx",
Data: FooNewParamsData{
FirstName: sapient.String("John"),
FirstName: githubcomusesapientgosdk.String("John"),
},
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Expand Down Expand Up @@ -440,7 +448,7 @@ func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response,
return res, err
}

client := sapient.NewClient(
client := githubcomusesapientgosdk.NewClient(
option.WithMiddleware(Logger),
)
```
Expand All @@ -465,7 +473,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/sapient-go/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/usesapient/go-sdk/issues) with questions, bugs, or suggestions.

## Contributing

Expand Down
4 changes: 4 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ before making any information public.
If you encounter security issues that are not directly related to SDKs but pertain to the services
or products provided by Sapient, please follow the respective company's security reporting guidelines.

### Sapient Terms and Policies

Please contact support@usesapient.com for any questions or concerns regarding the security of our services.

---

Thank you for helping us keep the SDKs and systems they interact with secure.
6 changes: 3 additions & 3 deletions aliases.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package sapient
package githubcomusesapientgosdk

import (
"github.com/stainless-sdks/sapient-go/internal/apierror"
"github.com/stainless-sdks/sapient-go/packages/param"
"github.com/usesapient/go-sdk/internal/apierror"
"github.com/usesapient/go-sdk/packages/param"
)

// aliased to make [param.APIUnion] private when embedding
Expand Down
34 changes: 0 additions & 34 deletions api.go

This file was deleted.

Loading
Loading