n4nAI

Topic

Go net/http LLM API Client

14 posts on go net/http llm api client — part of api integration on the n4n AI blog.

API integrationHow-to

Unmarshaling streaming JSON chunks in Go

A practical how-to for engineers building LLM clients: go unmarshal streaming json chunks in Go using net/http, json.Decoder, and backpressure.

3 min read
API integrationHow-to

Timeouts and context cancellation for Go LLM calls

Learn how to implement go context cancellation llm timeout patterns in Go HTTP clients to prevent hung LLM requests and waste spend.

3 min read
API integrationHow-to

Testing a Go LLM client with httptest

A practical guide to go httptest llm client testing: build mock OpenAI-compatible servers in Go, assert requests, and verify streaming responses.

3 min read
API integrationGuide

Structuring a Go package for multi-provider LLM clients

Practical guide to designing a Go package structure for LLM clients that span multiple providers, with interfaces, adapters, and fallback.

3 min read
API integrationTutorial

Request and response structs for OpenAI-compatible APIs

Hands-on tutorial: define Go request and response structs for OpenAI-compatible APIs and build a net/http client with runnable code.

2 min read
API integrationHow-to

Parsing OpenAI JSON responses with encoding/json in Go

Step-by-step guide to go encoding/json openai response parsing in Go: define structs, call the API with net/http, and handle errors robustly.

2 min read
API integrationComparison

net/http vs resty for calling LLM APIs in Go

A pragmatic head-to-head comparison of Go's net/http and resty for building LLM API clients: ergonomics, latency, retries, streaming, and verdicts.

4 min read
API integrationHow-to

Go generics for typed LLM provider responses

Learn how to apply Go generics to typed LLM provider response types, reducing duplication across OpenAI, Anthropic, and local model clients.

2 min read
API integrationGuide

Error handling patterns for Go LLM API clients

Practical guide to go error handling llm api client patterns in Go: implement timeouts, retries, typed errors, and provider fallback for robust LLM apps.

3 min read
API integrationGuide

Connection pooling for high-throughput LLM calls in Go

A practical guide to configuring Go's net/http client for high-throughput LLM API calls: transport pools, timeouts, and avoiding connection stalls.

3 min read
API integrationHow-to

Adding request tracing to a Go net/http LLM client

Learn how to implement go request tracing net/http llm clients with OpenTelemetry, context propagation, and per-request spans for production observability.

2 min read
API integrationHow-to

Handling rate limits with exponential backoff in Go

Learn how to implement Go exponential backoff rate limit handling for LLM APIs with net/http, including retryable errors, jitter, and Retry-After.

3 min read
API integrationTutorial

Build a chat completions client with Go net/http

Step-by-step tutorial for building a Go net/http chat completions client against OpenAI-compatible APIs, with structs, streaming, and error handling.

2 min read
API integrationHow-to

A custom Go http.RoundTripper for LLM API retries

Implement a go http.roundtripper retry llm api calls with backoff and body replay; a practical Go guide with runnable code for resilient LLM clients.

3 min read