Files
langchaingo/examples/openai-jsonformat-example
Dmitry Ng 064f09155c chore(deps): bump Go toolchain to 1.26.5 and fix vulnerable dependencies
- Raised the `go` directive from 1.24.1 to 1.26.5 to satisfy pgx/v5 and ollama's minimum Go version requirements and to pick up 15 patched standard library CVEs.
- Updated `pgx/v5`, `otel`/`otel/sdk`/`otlptracehttp`, `x/net`, and the AWS `eventstream` protocol package to their latest requested versions.
- Remediated govulncheck-flagged CVEs in `grpc`, `x/text`, `x/crypto`, `antchfx/xpath`, AWS SDK `bedrock*`/`s3` services, `etcd/server`, and `mongo-driver` v1/v2.
- Fixed ollama's `MainGPU` API type change (`int` -> `*int`) in `llms/ollama/options.go` without breaking the public `WithRunnerMainGPU` signature.
2026-08-04 13:57:26 +03:00
..
2025-01-07 15:03:47 +08:00

OpenAI STRUCTURED JSON Example

This example demonstrates how to use the OpenAI model with the LangChain Go library to generate structured JSON output.

What does this example do?

This nifty little program does the following:

  1. Sets up a connection to the OpenAI API using the GPT-4o model.

  2. Prompts the AI to generate a structured JSON output.

How to Run

  1. Make sure you have Go installed on your system.
  2. Set up your OpenAI API key as an environment variable.
  3. Run the program:
go run openai_jsonformat.go