Speakeasy CLI - Enterprise developer experience for your API

speakeasy-api speakeasy-api Last update: May 03, 2024



Speakeasy Logo

Enterprise-Ready Developer Experience for your REST API

Launch production-quality SDKs, Terraform providers, docs, and more in minutes πŸš€



Group 26

ezgif com-video-to-gif (1)


What is Speakeasy?

Speakeasy gives your users the developer experience that makes API integrations easy.

Don't put the burden of integration on your users. Take your APIs to market with best-in-class, enterprise-ready SDKs, Terraform providers, SDK docs, and more.

Group 27

Key Features

  • LLM Powered API Maintenance - Keep your API schema up to date and follow best practices with automatic maintenance powered by best-in-class LLMs. Try it out now in the CLI with speakeasy suggest or embed it into your GitHub workflow using our action.
  • Production-Quality SDKs - Ergonomic, type-safe, and fault-tolerant client libraries built for production use cases with idiomatics optimized for each language. Embed additional capabilities like auth, retries, pagination, and more using spec-based extensions.
  • Production-Quality Terraform Providers - Expose your API for infrastructure-as-code use cases with fully featured Terraform providers.
  • SDK Docs - Markdown usage snippets for every single operation and model in your SDK. Export usage snippets and host them on a branded SDK and API docs site using our Docusaurus React plugin.
  • Distribution to Package Managers - A complete pipeline for distributing your libraries to popular package managers like npm, PyPI, Maven, and Terraform Registry.
  • Supports Open Standards - Speakeasy works with your existing API framework by supporting OpenAPI3.X and other open standards. Plug and play not rip and replace.

For upcoming features and bug fixes, check out our public roadmap.

What is the Speakeasy CLI?

The Speakeasy CLI is a tool for interacting with the Speakeasy platform that brings the functionality of Speakeasy into your development workflow.

You can run the Speakeasy CLI locally or in your CI/CD pipeline to validate your API specs, generate SDKs, and more. Looking to embed this into your GitHub CI/CD? Check out these docs instead.

Here are a few key functions of the CLI:

  • generate - Generate idiomatic client SDKs from your API specs.
  • validate - Validate the correctness of your API specs. The CLI has a built-in command to validate your spec for SDK readiness and post helpful error messages.
  • suggest - Use an LLM to autocorrect your spec validation failures.
  • merge - Work with your existing documentation workflows by merging your API specs into a single spec.
  • auth - Authenticate with the platform and manage API keys.

For a complete list of commands check out our reference or type speakeasy and our interactive mode will take you through the available functions.

Design Choices

Each SDK generated by Speakeasy is idiomatic to the language it's generated for while sharing common patterns with SDKs for other languages to allow for switching between them. Using shared patterns also helps to keep the Speakeasy generation engine efficient while supporting many languages.

Here are some of the Speakeasy design decisions:

  • Each SDK generally implements a base SDK class that contains the methods for each of the API endpoints defined in the OpenAPI document.
  • Where possible, Speakeasy generates fully typed models from the OpenAPI document, separating models defined as components in the docs from models defined in line with operations.
  • Based on the configuration in the OpenAPI document, Speakeasy annotates types using reflection metadata to determine how to serialize and deserialize them.
  • To get SDKs to your end users quickly, Speakeasy generates full packages for each language that you should be able to publish to a package registry with little additional work. If you're interested in having a managed pipeline to your package manager, check out the Speakeasy Generation GitHub Action.

Want to learn more about the Speakeasy methodology? Take a look at how the Speakeasy SDK generator compares to OSS options.

If you're interested in generating managed GitHub repos for your SDKs or enterprise support, reach out to us or schedule a chat. We'd love to help you build out API DevEx.

If you're interested in having managed GitHub repos generated for your SDKs or enterprise support, reach out to us or schedule a chat. We'd love to help you build out API DevEx.

Speakeasy may capture metadata on usage of the Speakeasy CLI to better understand OpenAPI features so that we can build better code generators and other tools over time.

Installation

Homebrew (macOS and Linux)

brew install speakeasy-api/homebrew-tap/speakeasy

Script (macOS and Linux)

curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/install.sh | sh

Chocolatey (Windows)

choco install speakeasy

Manual Installation

Download the latest release for your platform from the releases page, extract, and add the binary to your path.

Keeping Up to Date

The CLI will warn you if you're running an outdated version. To update the CLI run:

speakeasy update

Alternatively, install the latest version via your package manager.

Getting Started With the Speakeasy CLI

Once you have installed the Speakeasy CLI, you can verify it's working by running:

speakeasy --help

See the Speakeasy docs for how to get started with the Speakeasy CLI.

Authenticating the Speakeasy CLI

The Speakeasy CLI depends on Speakeasy Platform APIs. Connect your Speakeasy CLI with the Speakeasy Platform by running:

speakeasy auth login

You'll be redirected to a login URL to select an existing workspace or create a new workspace on the platform. If your local network prevents you from accessing the login page prompted by the CLI, you can log in manually at app.speakeasyapi.dev, retrieve an API key, and populate a local environment variable named SPEAKEASY_API_KEY with the key.

Screenshot 2023-01-29 at 23 12 05

SDK Generation

Command:

speakeasy generate sdk [flags]

Options:

  -b, --baseurl string   base URL for the API (only required if OpenAPI spec doesn't specify root server URLs)
  -d, --debug            enable writing debug files with broken code
  -h, --help             help for SDK
  -l, --lang string      language to generate SDK for, defaults to go (available options: go, python, typescript, java)
  -o, --out string       path to the output directory
  -s, --schema string    path to the OpenAPI schema
  -y, --auto-yes string  auto answer yes to all prompts

Take a look at the Speakeasy getting started page for in-depth information.

Schema Validation

Note that you don't need to be logged in to the Speakeasy platform to validate your API schema.

Command:

speakeasy validate openapi [flags]

Options:

  -h, --help            help for OpenAPI
  -s, --schema string   path to the OpenAPI schema

OpenAPI Usage

Note that you don't need to be logged in to the Speakeasy platform to view OpenAPI usage information.

Command:

Use the following command to return usage information for a given OpenAPI schema to a CSV. Usage information includes counts of OpenAPI features.

speakeasy usage [flags]

Options:

  -d, --debug         enable writing debug files with broken code
  -f, --file string   path to file to generate usage information for
  -h, --help          help for usage
  -o, --out string    path to output file

OpenAPI Support

The tables below give an overview of what we support from OpenAPI.

βœ… Server Configuration

Name Notes Swagger Link Support
ServerURL config Global and per-method (include base URL and templating) api-host-and-base-path βœ…
Authentication and security Global and per-method authentication βœ…
Method generation βœ…
Model generation Request and response βœ…

⚠️ Path Parameters Serialization (path-parameters)

Name Notes Swagger Link Support
Default (style = simple, explode = false) serialization/#path βœ…
Basic types βœ…
Simple objects βœ…
label ❌
matrix ❌

⚠️ Query Parameters Serialization (query-parameters & query)

Name Notes Swagger Link Support
json βœ…
form βœ…
spaceDelimited βœ…
pipeDelimited βœ…
deepObject βœ…
Basic types βœ…
Simple objects βœ…

βœ… Request Headers (header)

Name Notes Swagger Link Support
Simple (explode = true) βœ…
Simple (explode = false) βœ…

⚠️ Request Body Serialization

Name Notes Swagger Link Support
Multipart encoding multi-part requests βœ…
Binary βœ…
Form data βœ…
JSON Both application/json and text/json βœ…
x-www-form-urlencoded Including encoding, but not non-object types describing-request-body ⚠️
Plain text βœ…
Raw byte βœ…
Handling required body βœ…
XML ❌
Other media types ❌

⚠️ Response Body Deserialization

Name Notes Swagger Link Support
Return StatusCode and Content-Type βœ…
JSON βœ…
Plain text βœ…
Raw byte βœ…
JSON βœ…
Other media types ❌

βœ… Media-Type Patterns (media-types)

βœ… Datatypes

Name Notes Swagger Link Support
Basic types data-models/data-types βœ…
Enums βœ…
Number formats float, double, int32, int64 βœ…
Date-time βœ…
Binary βœ…
Arrays βœ…
Objects βœ…
Optional βœ…
Maps βœ…
Any type βœ…
OneOf/AnyOf/AllOf anyOf treated as oneOf oneof-anyof-allof-not βœ…

βœ… Miscellaneous

Name Notes Swagger Link Support
Auxiliary files* βœ…
x-speakeasy-server-id generation βœ…
Snippet generation βœ…
README generation βœ…
Documentation generation βœ…

* Utility classes and functions to help with serialization and deserialization.

* Files needed for creating a fully compilable package that can be published to the relevant package manager without further changes.

Advanced Generation Features

Getting Support

If you need support using the Speakeasy CLI, please contact us via email, on Slack, or file a GitHub issue and we'll respond ASAP!

Usage

speakeasy [flags]

Options

  -h, --help   help for speakeasy

Sub Commands

CLI

speakeasy

The speakeasy cli tool provides access to the speakeasyapi.dev toolchain

Details

A cli tool for interacting with the Speakeasy https://www.speakeasyapi.dev/ platform and its various functions including: - Generating Client SDKs from OpenAPI specs (go, python, typescript, java, php, c#, swift, ruby, terraform) - Validating OpenAPI specs - Interacting with the Speakeasy API to create and manage your API workspaces - Generating OpenAPI specs from your API traffic - Generating Postman collections from OpenAPI Specs

Usage

speakeasy [flags]

Options

  -h, --help              help for speakeasy
      --logLevel string   the log level (available options: [info, warn, error]) (default "info")

Sub Commands

Subscribe to our newsletter