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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
docs add response format on main pages
Ishaan Jaffd1124a736ce1
diff --git a/docs/my-website/docs/index.md b/docs/my-website/docs/index.mdindex 4c48c868fc3..e5c3fdaa3be 100644--- a/docs/my-website/docs/index.md+++ b/docs/my-website/docs/index.md@@ -67,7 +67,7 @@ import osos.environ["OPENAI_API_KEY"] = "your-api-key"response = completion(- model="gpt-3.5-turbo",+ model="openai/gpt-4o",messages=[{ "content": "Hello, how are you?","role": "user"}])```@@ -83,7 +83,7 @@ import osos.environ["ANTHROPIC_API_KEY"] = "your-api-key"response = completion(- model="claude-2",+ model="anthropic/claude-3-sonnet-20240229",messages=[{ "content": "Hello, how are you?","role": "user"}])```@@ -101,7 +101,7 @@ os.environ["VERTEX_PROJECT"] = "hardy-device-386718"os.environ["VERTEX_LOCATION"] = "us-central1"response = completion(- model="chat-bison",+ model="vertex_ai/gemini-1.5-pro",messages=[{ "content": "Hello, how are you?","role": "user"}])```@@ -180,6 +180,42 @@ response = completion(</Tabs>+### Response Format (OpenAI Format)++```json+{+ "id": "chatcmpl-565d891b-a42e-4c39-8d14-82a1f5208885",+ "created": 1734366691,+ "model": "claude-3-sonnet-20240229",+ "object": "chat.completion",+ "system_fingerprint": null,+ "choices": [+ {+ "finish_reason": "stop",+ "index": 0,+ "message": {+ "content": "Hello! As an AI language model, I don't have feelings, but I'm operating properly and ready to assist you with any questions or tasks you may have. How can I help you today?",+ "role": "assistant",+ "tool_calls": null,+ "function_call": null+ }+ }+ ],+ "usage": {+ "completion_tokens": 43,+ "prompt_tokens": 13,+ "total_tokens": 56,+ "completion_tokens_details": null,+ "prompt_tokens_details": {+ "audio_tokens": null,+ "cached_tokens": 0+ },+ "cache_creation_input_tokens": 0,+ "cache_read_input_tokens": 0+ }+}+```+### StreamingSet `stream=True` in the `completion` args.@@ -194,7 +230,7 @@ import osos.environ["OPENAI_API_KEY"] = "your-api-key"response = completion(- model="gpt-3.5-turbo",+ model="openai/gpt-4o",messages=[{ "content": "Hello, how are you?","role": "user"}],stream=True,)@@ -211,7 +247,7 @@ import osos.environ["ANTHROPIC_API_KEY"] = "your-api-key"response = completion(- model="claude-2",+ model="anthropic/claude-3-sonnet-20240229",messages=[{ "content": "Hello, how are you?","role": "user"}],stream=True,)@@ -230,7 +266,7 @@ os.environ["VERTEX_PROJECT"] = "hardy-device-386718"os.environ["VERTEX_LOCATION"] = "us-central1"response = completion(- model="chat-bison",+ model="vertex_ai/gemini-1.5-pro",messages=[{ "content": "Hello, how are you?","role": "user"}],stream=True,)@@ -314,6 +350,32 @@ response = completion(</Tabs>+### Streaming Response Format (OpenAI Format)++```json+{+ "id": "chatcmpl-2be06597-eb60-4c70-9ec5-8cd2ab1b4697",+ "created": 1734366925,+ "model": "claude-3-sonnet-20240229",+ "object": "chat.completion.chunk",+ "system_fingerprint": null,+ "choices": [+ {+ "finish_reason": null,+ "index": 0,+ "delta": {+ "content": "Hello",+ "role": "assistant",+ "function_call": null,+ "tool_calls": null,+ "audio": null+ },+ "logprobs": null+ }+ ]+}+```+### Exception handlingLiteLLM maps exceptions across all supported providers to the OpenAI exceptions. All our exceptions inherit from OpenAI's exception types, so any error-handling you have for that, should work out of the box with LiteLLM.