Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

feat(utils.py): Add github as a provider

Krrish Dholakia4258295a079c
diff --git a/litellm/__init__.py b/litellm/__init__.py
index 0bbccf82719..f11d117b039 100644
--- a/litellm/__init__.py
+++ b/litellm/__init__.py
@@ -458,6 +458,7 @@ openai_compatible_providers: List = [
"empower",
"friendliai",
"azure_ai",
+ "github",
]
@@ -698,6 +699,7 @@ provider_list: List = [
"predibase",
"databricks",
"empower",
+ "github",
"custom", # custom apis
]
diff --git a/litellm/tests/test_completion.py b/litellm/tests/test_completion.py
index df5f693f739..c26035ad0ad 100644
--- a/litellm/tests/test_completion.py
+++ b/litellm/tests/test_completion.py
@@ -344,6 +344,36 @@ def test_completion_empower():
pytest.fail(f"Error occurred: {e}")
+def test_completion_github_api():
+ litellm.set_verbose = True
+ messages = [
+ {
+ "role": "user",
+ "content": "\nWhat is the query for `console.log` => `console.error`\n",
+ },
+ {
+ "role": "assistant",
+ "content": "\nThis is the GritQL query for the given before/after examples:\n<gritql>\n`console.log` => `console.error`\n</gritql>\n",
+ },
+ {
+ "role": "user",
+ "content": "\nWhat is the query for `console.info` => `consdole.heaven`\n",
+ },
+ ]
+ try:
+ # test without max tokens
+ response = completion(
+ model="github/gpt-4o",
+ messages=messages,
+ )
+ # Add any assertions, here to check response args
+ print(response)
+ except litellm.AuthenticationError:
+ pass
+ except Exception as e:
+ pytest.fail(f"Error occurred: {e}")
+
+
def test_completion_claude_3_empty_response():
litellm.set_verbose = True
diff --git a/litellm/utils.py b/litellm/utils.py
index 713fe4f2ae5..b6d00536f4d 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -4513,6 +4513,10 @@ def get_llm_provider(
elif custom_llm_provider == "azure_ai":
api_base = api_base or get_secret("AZURE_AI_API_BASE") # type: ignore
dynamic_api_key = api_key or get_secret("AZURE_AI_API_KEY")
+ elif custom_llm_provider == "github":
+ api_base = api_base or get_secret("GITHUB_API_BASE") or "https://models.inference.ai.azure.com" # type: ignore
+ dynamic_api_key = api_key or get_secret("GITHUB_API_KEY")
+
elif custom_llm_provider == "mistral":
# mistral is openai compatible, we just need to set this to custom_openai and have the api_base be https://api.mistral.ai
api_base = (