Skip to main content
The Go SDK and docs are currently in beta. Report issues on GitHub.
Response format configuration

Supported Types

ChatFormatGrammarConfig

responseFormat := components.CreateResponseFormatGrammar(components.ChatFormatGrammarConfig{/* values here */})

FormatJSONObjectConfig

responseFormat := components.CreateResponseFormatJSONObject(components.FormatJSONObjectConfig{/* values here */})

ChatFormatJSONSchemaConfig

responseFormat := components.CreateResponseFormatJSONSchema(components.ChatFormatJSONSchemaConfig{/* values here */})

ChatFormatPythonConfig

responseFormat := components.CreateResponseFormatPython(components.ChatFormatPythonConfig{/* values here */})

ChatFormatTextConfig

responseFormat := components.CreateResponseFormatText(components.ChatFormatTextConfig{/* values here */})

Union Discrimination

Use the Type field to determine which variant is active, then access the corresponding field:
switch responseFormat.Type {
	case components.ResponseFormatTypeGrammar:
		// responseFormat.ChatFormatGrammarConfig is populated
	case components.ResponseFormatTypeJSONObject:
		// responseFormat.FormatJSONObjectConfig is populated
	case components.ResponseFormatTypeJSONSchema:
		// responseFormat.ChatFormatJSONSchemaConfig is populated
	case components.ResponseFormatTypePython:
		// responseFormat.ChatFormatPythonConfig is populated
	case components.ResponseFormatTypeText:
		// responseFormat.ChatFormatTextConfig is populated
}