dexter icon indicating copy to clipboard operation
dexter copied to clipboard

Feat/add grok api key

Open dimaland1 opened this issue 1 month ago • 2 comments

Summary

This PR adds xAI (Grok) as a new LLM provider, expanding Dexter's multi-provider capabilities alongside OpenAI, Anthropic, Google, and Ollama.

Why xAI/Grok?

  • Cutting-edge reasoning: Grok models excel at complex reasoning tasks and real-time information processing
  • Fast inference: grok-4-1-fast-reasoning offers optimized speed for tool calling and agentic workflows
  • OpenAI-compatible API: Seamless integration using existing LangChain infrastructure
  • Growing ecosystem: xAI is rapidly evolving with competitive pricing and unique capabilities

Changes

LLM Integration (src/model/llm.ts)

  • Add grok- prefix handler routing to xAI API at https://api.x.ai/v1
  • Register grok-4-1-fast-reasoning as fast model variant for lightweight tasks
  • Use XAI_API_KEY environment variable for authentication

Model Selector (src/components/ModelSelector.tsx)

  • Add xAI to provider list with display name and available models
  • Support grok-4-0709 (flagship) and grok-4-1-fast-reasoning (optimized)
  • Auto-detect xAI provider for models starting with grok-

Developer Experience

  • Add file logging system (logs/dexter.log) for easier debugging
  • Logs include financial search routing, tool calls, and API responses
  • File-only logging option to avoid cluttering the CLI

Configuration

  • Add XAI_API_KEY to env.example

Test plan

  • [ ] Configure XAI_API_KEY in .env
  • [ ] Launch Dexter and run /model
  • [ ] Verify xAI appears as a selectable provider
  • [ ] Select grok-4-0709 or grok-4-1-fast-reasoning
  • [ ] Send a test prompt and verify response
  • [ ] Test financial query to confirm tool calling works (e.g., "What is Apple's stock price?")
  • [ ] Check logs/dexter.log for debug output

dimaland1 avatar Jan 17 '26 01:01 dimaland1

These logs were created for debugging and call tracking. If you don't find them helpful, i will remove them.

dimaland1 avatar Jan 17 '26 03:01 dimaland1

Hey! @virattt I've removed the file logging changes as requested. The PR now only contains the xAI (Grok) integration:

  • LLM provider config with grok- prefix handler
  • ModelSelector update with Grok models
  • README documentation
  • env.example with XAI_API_KEY

Clean single commit, ready for review!

dimaland1 avatar Jan 17 '26 13:01 dimaland1