What is gRPC?
Using this feature in generated SDKs requires the Enterprise plan. To get started, reach out to support@buildwithfern.com.
Fern only supports gRPC SDK generation for .NET/C#. Protobuf specs can be used for documentation generation in all languages. File an issue to request additional languages.
gRPC is a modern, open-source, high-performance Remote Procedure Call (RPC) framework that can run in any environment. It uses Protocol Buffers (protobuf) as the interface definition language and supports multiple programming languages.
Fern is compatible with gRPC services and can generate SDKs and documentation from your .proto files.
For a working example, see the gRPC demo docs and its GitHub repository.
Below is an example of a gRPC service definition:
Get started with fern init
fern init creates a fern/ folder with a generators.yml that generates a C# SDK. Run it from your project root.
--grpc creates a sample unary service. --proto takes a local path, copies the .proto files into fern/proto/, and adds the google/api protos if they’re imported and missing. target is set to the file that defines a service; when several files define one, target is omitted and every file is compiled. The two flags can’t be combined with each other or with --openapi, --fern-definition, --docs, --mintlify, or --readme. See the generators.yml reference for configuration options.
Then generate the SDK:
fern generate compiles the .proto files on your machine, downloading buf the first time, and builds the SDK in Fern’s cloud. The SDK is written to sdks/csharp.
Supported proto features
The C# SDK supports unary RPCs. Streaming RPCs (server, client, and bidirectional) aren’t supported yet. fern init --proto warns you if your files use them.
Other languages
Only the C# SDK contains a gRPC client. For other languages, Fern converts the proto to OpenAPI and generates a REST client that follows the google.api.http routes. These clients send HTTP/JSON, which a native gRPC server doesn’t accept, so they require a gateway in front of the server that translates HTTP/JSON to gRPC, such as grpc-gateway or Envoy’s gRPC-JSON transcoder. Streaming RPCs are generated as plain POST methods and don’t stream.
Get help
If you run into issues, reach out to support@buildwithfern.com.