Feature Request: Add thinking_config to _API_CONFIG_KEYS for Gemini 3 model support
- Dominant language
- Python
- Stars
- 38.6k
- Forks
- 2.7k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 3
Description
## Summary
When using Gemini 3 models (`gemini-3-flash-preview`, `gemini-3-pro-preview`) with LangExtract, the API calls timeout because **Gemini 3 defaults to `thinking_level: high`** which adds significant latency. There's currently no way to pass `thinking_config` to reduce this latency.
## Problem
The `_API_CONFIG_KEYS` allowlist in `langextract/providers/gemini.py` (line 40-48) does not include `thinking_config`:
```python
_API_CONFIG_KEYS: Final[set[str]] = {
'response_mime_type',
'response_schema',
'safety_settings',
'system_instruction',
'tools',
'stop_sequences',
'candidate_count',
}
```
This means any `thinking_config` passed via `language_model_params` gets filtered out (line 186-188):
```python
self._extra_kwargs = {
k: v for k, v in (kwargs or {}).items() if k in _API_CONFIG_KEYS
}
```
## Impact
- **Gemini 3 Flash** (designed for speed) times out on simple extraction tasks
- Users cannot set `thinking_level: "minimal"` to reduce latency
- Forces users to use older models like `gemini-2.5-flash` instead of newer Gemini 3 models
## Proposed Solution
Add `thinking_config` to `_API_CONFIG_KEYS`:
```python
_API_CONFIG_KEYS: Final[set[str]] = {
'response_mime_type',
'response_schema',
'safety_settings',
'system_instruction',
'tools',
'stop_sequences',
'candidate_count',
'thinking_config', # Add this for Gemini 3 support
}
```
This would allow users to pass:
```python
result = lx.extract(
text_or_documents=text,
prompt_description=prompt,
examples=examples,
model_id="gemini-3-flash-preview",
language_model_params={
"thinking_config": {"thinking_level": "minimal"}
}
)
```
## References
- [Gemini 3 Developer Guide - thinking_level parameter](https://ai.google.dev/gemini-api/docs/gemini-3)
- [Gemini Thinking Documentation](https://ai.google.dev/gemini-api/docs/thinking)
## Environment
- LangExtract version: 1.1.1
- Python: 3.12
- Models tested: `gemini-3-flash-preview`, `gemini-3-pro-preview`
Contributor guide
Research direction
Read langextract/providers/gemini.py around _API_CONFIG_KEYS at lines 40-48 and the filtering at lines 186-188. Confirm that thinking_config is removed from language_model_params, then verify that the Gemini 3 example can pass thinking_level: minimal after the allowlist change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100