mcpField
C
configure-sdk-options

configure-sdk-options

github.com/speakeasy-apiDevelopment1894 installsUpdated 37w ago
Repository

About configure-sdk-options

A skill for configuring `gen.yaml` in an existing Speakeasy SDK, intended for developers adjusting language-specific generation and runtime options. It covers seven SDK languages, custom hooks, and per-call overrides; it is not for creating a new SDK.

Key features

  1. 01Configure `gen.yaml` for seven languages
  2. 02Set async modes and SDK hooks
  3. 03Override retries, timeouts, and servers
  4. 04Configure pagination and publishing options

Use cases

  1. 01Adjust generation settings for an existing SDK
  2. 02Set runtime retry or timeout behavior
  3. 03Switch configured API servers at runtime

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/speakeasy-api/sdk-generation-skills --skill configure-sdk-options

After installing, type/configure-sdk-optionsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

content/languages/
csharp.md
go.md
java.md
php.md
python.md
ruby.md
typescript.md

Details

From the project README

Configure SDK Options

Configure gen.yaml options for an existing Speakeasy SDK. Supports TypeScript, Python, Go, Java, C#, PHP, and Ruby.

For new SDK projects: Use start-new-sdk-project skill instead. This skill is for configuring an existing SDK.

Language-Specific Guides

For comprehensive configuration details, see the language-specific guides:

LanguageGuideKey Features
TypeScriptcontent/languages/typescript.mdZod validation, React Query, standalone functions, dual module format
Pythoncontent/languages/python.mdPydantic models, async modes (both/split), uv/poetry support
Gocontent/languages/go.mdResponse formats, interface generation, K8s integration
Javacontent/languages/java.mdBuilder pattern, Gradle customization, Maven Central publishing
C#content/languages/csharp.mdAsync/await, cancellation tokens, DI integration, NuGet
PHPcontent/languages/php.mdLaravel integration, Guzzle config, Packagist publishing
Rubycontent/languages/ruby.mdSorbet typing, Rails integration, RubyGems publishing

These guides include detailed configuration options, code examples, framework integrations, and publishing instructions.

When to Use

  • Configuring language-specific gen.yaml options on an existing SDK
  • Setting up SDK hooks, async patterns, or publishing
  • Configuring runtime behavior (retries, timeouts, server selection) in application code
  • User says: "configure SDK", "gen.yaml options", "SDK config", "runtime override", "per-call config"
  • User asks about: Zod, Pydantic, NuGet, PyPI, npm, Maven Central, Packagist, RubyGems

Inputs

InputRequiredDescription
Existing SDKYesSDK with .speakeasy/workflow.yaml already created
Target languageYesTypeScript, Python, Go, Java, C#, PHP, or Ruby

Outputs

OutputDescription
Updated gen.yamlLanguage-specific configuration
Hook filesCustom hooks if enabled

Prerequisites

You must have an existing SDK with .speakeasy/workflow.yaml. If not, run:

speakeasy quickstart --skip-interactive --output console \
  -s openapi.yaml -t <language> -n "MySDK" -p "<package-name>"

Common Configuration (All Languages)

These options apply to all SDK targets in gen.yaml:

<language>:
  version: 1.0.0
  packageName: "my-sdk"

  # Method signatures
  maxMethodParams: 4              # Params before request object
  flatteningOrder: parameters-first

  # Error handling
  responseFormat: flat            # or "envelope" (Go)
  clientServerStatusCodesAsErrors: true

TypeScript Configuration

typescript:
  version: 1.0.0
  packageName: "@myorg/my-sdk"
  moduleFormat: dual              # esm, commonjs, or dual
  zodVersion: v4-mini             # v3, v4, or v4-mini
  enableCustomCodeRegions: true   # For custom code
  enableReactQuery: true          # React Query hooks
FeatureNotes
Zod validationAutomatic for all models
Tree-shakingUse moduleFormat: dual + standalone functions
JSR publishingCreate jsr.json, run deno publish
npm publishingStandard npm publish

Standalone functions for tree-shaking:

import { TodoCore } from "my-sdk/core.js";
import { todosCreate } from "my-sdk/funcs/todosCreate.js";
const sdk = new TodoCore({ apiKey: "..." });

Python Configuration

python:
  version: 1.0.0
  packageName: "my-sdk"
  asyncMode: both                 # both or split
  packageManager: uv              # uv or poetry
  envVarPrefix: ""                # Prefix for env config
FeatureNotes
Pydantic modelsAutomatic for all models
Async mode bothsdk.method() and sdk.method_async()
Async mode splitSDK() and AsyncSDK() constructors
PyPI publishinguv publish or poetry publish

Async patterns:

# asyncMode: both (default)
result = sdk.users.list()           # sync
result = await sdk.users.list_async() # async

# asyncMode: split
sdk = MySDK()                       # sync only
async_sdk = AsyncMySDK()            # async only

Go Configuration

go:
  version: 0.1.0
  packageName: github.com/myorg/my-sdk
  maxMethodParams: 2
  methodArguments: require-security-and-request
  responseFormat: envelope
  flattenGlobalSecurity: true
FeatureNotes
InterfacesGenerate with ifacemaker
MocksGenerate with mockery
K8s integrationAdd kubebuilder markers, run controller-gen

Interface generation for testing:

go install github.com/vburenin/ifacemaker@latest
go install github.com/vektra/mockery/v2@latest
ifacemaker --file consumers.go --struct Consumers --iface ConsumersSDK --output consumers_i.go
mockery

Java Configuration

java:
  version: 1.0.0
  groupID: com.myorg
  artifactID: my-sdk
  packageName: com.myorg.mysdk
  methodArguments: require-security-and-request
FeatureNotes
Builder patternAutomatic for all classes
Build customizationUse build-extras.gradle (preserved)
Maven Central./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository

Client usage:

MySdk sdk = MySdk.builder()
    .security(Security.builder().apiKey("key").build())
    .build();

C# Configuration

csharp:
  version: 1.0.0
  packageName: MyOrg.MySDK
  dotnetVersion: "6.0"
  baseErrorName: MySDKException
FeatureNotes
Async/awaitAll operations async by default
SSE streamingEventStream<T> support
NuGet publishingdotnet pack -c Release && dotnet nuget push

Async with cancellation:

var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
var result = await sdk.Users.ListAsync(cancellationToken: cts.Token);

PHP Configuration

php:
  version: 1.0.0
  packageName: myorg/my-sdk
  namespace: MyOrg\MySDK
FeatureNotes
PHP 8.2+Required minimum version
GuzzleHTTP client (configurable timeout)
PackagistTag release, register on Packagist.org

Security callback for token refresh:

$sdk = MySDK\MySDK::builder()
    ->setSecuritySource(fn() => getTokenFromCache() ?? refreshToken())
    ->build();

Ruby Configuration

ruby:
  version: 1.0.0
  packageName: my-sdk
  module: MySdk
  typingStrategy: sorbet          # sorbet or none
FeatureNotes
Sorbet typingOptional, enable with typingStrategy: sorbet
FaradayHTTP client
RubyGemsgem build && gem push

SDK Hooks (All Languages)

Enable custom hooks with enableCustomCodeRegions: true. Hook files are preserved across regeneration.

LanguageHook Location
TypeScriptsrc/hooks/
Pythonsrc/<pkg>/_hooks/
Gointernal/hooks/
Javasrc/main/java/.../hooks/
C#src/.../Hooks/
PHPsrc/Hooks/
Rubylib/.../sdk_hooks/

See customize-sdk-hooks skill for detailed hook implementation.

Runtime Overrides

Runtime behavior can be configured at SDK instantiation or per-call. These override gen.yaml defaults.

Server Selection

Define server IDs in OpenAPI spec, then select at runtime:

# OpenAPI spec
servers:
  - url: https://api.example.com
    x-speakeasy-server-id: production
  - url: https://sandbox.example.com
    x-speakeasy-server-id: sandbox
LanguageSDK ConstructorCustom URL
TypeScriptnew SDK({ server: "sandbox" })new SDK({ serverURL: "..." })
PythonSDK(server="sandbox")SDK(server_url="...")
GoSDK.New(SDK.WithServer("sandbox"))SDK.WithServerURL("...")
Retry Overrides

Override retry behavior per-call (spec defaults set via x-speakeasy-retries):

TypeScript:

const res = await sdk.payments.create({ amount: 1000 }, {
  retries: {
    strategy: "backoff",
    backoff: { initialInterval: 1000, maxInterval: 30000, maxElapsedTime: 120000, exponent: 2.0 },
    retryConnectionErrors: true,
  },
});

Python:

from sdk.utils import BackoffStrategy, RetryConfig
res = sdk.payments.create(amount=1000, retries=RetryConfig("backoff",
    backoff=BackoffStrategy(1000, 30000, 120000, 2.0), retry_connection_errors=True))

Go:

res, err := sdk.Payments.Create(ctx, req, operations.WithRetries(retry.Config{
    Strategy: "backoff", Backoff: &retry.BackoffStrategy{
        InitialInterval: 1000, MaxInterval: 30000, MaxElapsedTime: 120000, Exponent: 2.0},
    RetryConnectionErrors: true}))
Timeout Overrides

Set global timeout on SDK constructor, or per-call:

LanguageGlobalPer-call
TypeScriptnew SDK({ timeoutMs: 30000 })sdk.op({}, { timeoutMs: 60000 })
PythonSDK(timeout_ms=30000)sdk.op(timeout_ms=60000)
GoSDK.WithTimeoutMs(30000)operations.WithTimeoutMs(60000)
Pagination Usage

SDK auto-generates pagination helpers when x-speakeasy-pagination is set in spec:

// Auto-iterate all pages
for await (const user of await sdk.users.list({ limit: 50 })) {
  console.log(user.name);
}

// Manual pagination
let page = await sdk.users.list({ limit: 50 });
while (page) {
  for (const user of page.data) { console.log(user.name); }
  page = await page.next();
}

Decision Framework

SituationAction
Need tree-shaking (TS)Set moduleFormat: dual, use standalone functions
Need async/sync (Python)Set asyncMode: both (default)
Need separate async clientSet asyncMode: split (Python)
Need interfaces for testing (Go)Use ifacemaker + mockery
Need custom build config (Java)Edit build-extras.gradle
Need runtime retry overridePass retries config in per-call options
Need runtime timeout overrideSet timeoutMs on constructor or per-call
Need server switchingUse x-speakeasy-server-id in spec, select at runtime

What NOT to Do

  • Do NOT use this skill for initial SDK generation - use start-new-sdk-project
  • Do NOT edit generated files outside custom code regions
  • Do NOT modify files in src/ that aren't in preserved directories (hooks, extra)

Troubleshooting

LanguageIssueSolution
TypeScriptBundle too largeUse standalone functions
PythonAsync pagination blockingEnable fixFlags.asyncPaginationSep2025: true
GoInterface not generatedEnsure struct is exported (capitalized)
JavaGradle sync failsRun ./gradlew --refresh-dependencies
C#Async deadlockUse await not .Result
PHPPHP version errorRequires PHP 8.2+
RubySorbet errorsRun bundle exec tapioca gems
AllRetries not workingEnsure x-speakeasy-retries at document root or operation level
AllServer ID not recognizedAdd x-speakeasy-server-id to each server entry
AllPagination next() undefinedAdd x-speakeasy-pagination to the list operation

After Making Changes

After modifying gen.yaml configuration, prompt the user to regenerate the SDK:

Configuration complete. Would you like to regenerate the SDK now with speakeasy run?

If the user confirms, run:

speakeasy run --output console

Changes to gen.yaml only take effect after regeneration.

Related Skills

  • start-new-sdk-project - Initial SDK generation
  • customize-sdk-hooks - Detailed hook implementation
  • manage-openapi-overlays - Spec customization

Comments

Markdown supported