> ## Documentation Index
> Fetch the complete documentation index at: https://openrouter-d02e98a0-mintlify-7021d5f4.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ResponseFormat - Go SDK

> ResponseFormat type definition

<Warning>
  The Go SDK and docs are currently in beta.
  Report issues on [GitHub](https://github.com/OpenRouterTeam/go-sdk/issues).
</Warning>

Response format configuration

## Supported Types

### ChatFormatGrammarConfig

```go lines theme={null}
responseFormat := components.CreateResponseFormatGrammar(components.ChatFormatGrammarConfig{/* values here */})
```

### FormatJSONObjectConfig

```go lines theme={null}
responseFormat := components.CreateResponseFormatJSONObject(components.FormatJSONObjectConfig{/* values here */})
```

### ChatFormatJSONSchemaConfig

```go lines theme={null}
responseFormat := components.CreateResponseFormatJSONSchema(components.ChatFormatJSONSchemaConfig{/* values here */})
```

### ChatFormatPythonConfig

```go lines theme={null}
responseFormat := components.CreateResponseFormatPython(components.ChatFormatPythonConfig{/* values here */})
```

### ChatFormatTextConfig

```go lines theme={null}
responseFormat := components.CreateResponseFormatText(components.ChatFormatTextConfig{/* values here */})
```

## Union Discrimination

Use the `Type` field to determine which variant is active, then access the corresponding field:

```go lines theme={null}
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
}
```
