akhaliq HF Staff commited on
Commit
66d2544
·
1 Parent(s): 750aff3

add grok code fast

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -1485,6 +1485,11 @@ CRITICAL: For imported spaces that lack anycoder attribution, you MUST add it as
1485
 
1486
  # Available models
1487
  AVAILABLE_MODELS = [
 
 
 
 
 
1488
  {
1489
  "name": "Moonshot Kimi-K2",
1490
  "id": "moonshotai/Kimi-K2-Instruct",
@@ -1691,7 +1696,7 @@ AVAILABLE_MODELS = [
1691
  ]
1692
 
1693
  # Default model selection
1694
- DEFAULT_MODEL_NAME = "Magistral Medium 2509"
1695
  DEFAULT_MODEL = None
1696
  for _m in AVAILABLE_MODELS:
1697
  if _m.get("name") == DEFAULT_MODEL_NAME:
@@ -1829,6 +1834,16 @@ def get_inference_client(model_id, provider="auto"):
1829
  api_key=os.getenv("OPENROUTER_API_KEY"),
1830
  base_url="https://openrouter.ai/api/v1",
1831
  )
 
 
 
 
 
 
 
 
 
 
1832
  elif model_id == "step-3":
1833
  # Use StepFun API client for Step-3 model
1834
  return OpenAI(
 
1485
 
1486
  # Available models
1487
  AVAILABLE_MODELS = [
1488
+ {
1489
+ "name": "Grok 4 Fast (Free)",
1490
+ "id": "x-ai/grok-4-fast:free",
1491
+ "description": "X.AI Grok 4 Fast model via OpenRouter - free tier with vision capabilities for code generation"
1492
+ },
1493
  {
1494
  "name": "Moonshot Kimi-K2",
1495
  "id": "moonshotai/Kimi-K2-Instruct",
 
1696
  ]
1697
 
1698
  # Default model selection
1699
+ DEFAULT_MODEL_NAME = "Grok 4 Fast (Free)"
1700
  DEFAULT_MODEL = None
1701
  for _m in AVAILABLE_MODELS:
1702
  if _m.get("name") == DEFAULT_MODEL_NAME:
 
1834
  api_key=os.getenv("OPENROUTER_API_KEY"),
1835
  base_url="https://openrouter.ai/api/v1",
1836
  )
1837
+ elif model_id == "x-ai/grok-4-fast:free":
1838
+ # Use OpenRouter client for Grok 4 Fast (Free) model
1839
+ return OpenAI(
1840
+ api_key=os.getenv("OPENROUTER_API_KEY"),
1841
+ base_url="https://openrouter.ai/api/v1",
1842
+ default_headers={
1843
+ "HTTP-Referer": "https://huggingface.co/spaces/akhaliq/anycoder",
1844
+ "X-Title": "anycoder"
1845
+ }
1846
+ )
1847
  elif model_id == "step-3":
1848
  # Use StepFun API client for Step-3 model
1849
  return OpenAI(