{
    "info": {
        "_postman_id": "b7c2a1e0-9f3d-4a52-bf10-aa01c2d3e4f5",
        "name": "AI Services Gateway API",
        "description": "Unified gateway exposing both an OpenAI Chat Completions-compatible API and the native Ollama chat API.\n\nSetup:\n1. Import this collection AND the `postman_environment.json` environment.\n2. Select the \"AI Gateway\" environment (top-right).\n3. Set `base_url` and `api_key` in the environment.\n\nAll requests authenticate with `Authorization: Bearer {{api_key}}`. The `model` field is accepted for SDK compatibility but the gateway always enforces the model bound to your API key.",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    },
    "auth": {
        "type": "bearer",
        "bearer": [
            { "key": "token", "value": "{{api_key}}", "type": "string" }
        ]
    },
    "variable": [
        { "key": "base_url", "value": "https://api.adelk.sa/llm" },
        { "key": "api_key", "value": "YOUR_API_KEY_HERE" }
    ],
    "item": [
        {
            "name": "OpenAI-Compatible",
            "description": "Endpoint: POST {{base_url}}/api/v1/chat/completions — returns OpenAI Chat Completion objects (SSE when streaming).",
            "item": [
                {
                    "name": "Chat Completion (non-stream)",
                    "request": {
                        "method": "POST",
                        "header": [
                            { "key": "Content-Type", "value": "application/json" },
                            { "key": "Authorization", "value": "Bearer {{api_key}}" }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"model\": \"assigned-by-key\",\n    \"messages\": [\n        { \"role\": \"system\", \"content\": \"You are a helpful assistant.\" },\n        { \"role\": \"user\", \"content\": \"Explain quantum computing in one sentence.\" }\n    ],\n    \"temperature\": 0.7,\n    \"max_tokens\": 256,\n    \"stream\": false\n}"
                        },
                        "url": {
                            "raw": "{{base_url}}/api/v1/chat/completions",
                            "host": [ "{{base_url}}" ],
                            "path": [ "api", "v1", "chat", "completions" ]
                        },
                        "description": "Standard OpenAI chat completion. Works with any OpenAI SDK by pointing base_url at {{base_url}}/api/v1."
                    },
                    "response": []
                },
                {
                    "name": "Chat Completion (streaming SSE)",
                    "request": {
                        "method": "POST",
                        "header": [
                            { "key": "Content-Type", "value": "application/json" },
                            { "key": "Authorization", "value": "Bearer {{api_key}}" },
                            { "key": "Accept", "value": "text/event-stream" }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"model\": \"assigned-by-key\",\n    \"messages\": [\n        { \"role\": \"user\", \"content\": \"Write a haiku about the sea.\" }\n    ],\n    \"stream\": true,\n    \"stream_options\": { \"include_usage\": true }\n}"
                        },
                        "url": {
                            "raw": "{{base_url}}/api/v1/chat/completions",
                            "host": [ "{{base_url}}" ],
                            "path": [ "api", "v1", "chat", "completions" ]
                        },
                        "description": "Server-Sent Events stream of `chat.completion.chunk` objects, terminated by `data: [DONE]`. With stream_options.include_usage a final usage-only chunk is emitted before [DONE]."
                    },
                    "response": []
                },
                {
                    "name": "Vision (image input)",
                    "request": {
                        "method": "POST",
                        "header": [
                            { "key": "Content-Type", "value": "application/json" },
                            { "key": "Authorization", "value": "Bearer {{api_key}}" }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"model\": \"assigned-by-key\",\n    \"messages\": [\n        {\n            \"role\": \"user\",\n            \"content\": [\n                { \"type\": \"text\", \"text\": \"What is in this image?\" },\n                { \"type\": \"image_url\", \"image_url\": { \"url\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==\" } }\n            ]\n        }\n    ]\n}"
                        },
                        "url": {
                            "raw": "{{base_url}}/api/v1/chat/completions",
                            "host": [ "{{base_url}}" ],
                            "path": [ "api", "v1", "chat", "completions" ]
                        },
                        "description": "Multimodal content. Only base64 data: URIs are forwarded (remote URLs are dropped for SSRF safety). Requires a key with Vision enabled and a vision-capable model."
                    },
                    "response": []
                },
                {
                    "name": "Tool / Function calling",
                    "request": {
                        "method": "POST",
                        "header": [
                            { "key": "Content-Type", "value": "application/json" },
                            { "key": "Authorization", "value": "Bearer {{api_key}}" }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"model\": \"assigned-by-key\",\n    \"messages\": [\n        { \"role\": \"user\", \"content\": \"What is the weather in Riyadh today?\" }\n    ],\n    \"tools\": [\n        {\n            \"type\": \"function\",\n            \"function\": {\n                \"name\": \"get_weather\",\n                \"description\": \"Get the current weather for a city\",\n                \"parameters\": {\n                    \"type\": \"object\",\n                    \"properties\": { \"city\": { \"type\": \"string\" } },\n                    \"required\": [\"city\"]\n                }\n            }\n        }\n    ],\n    \"tool_choice\": \"auto\"\n}"
                        },
                        "url": {
                            "raw": "{{base_url}}/api/v1/chat/completions",
                            "host": [ "{{base_url}}" ],
                            "path": [ "api", "v1", "chat", "completions" ]
                        },
                        "description": "Function/tool calling. Requires a key with Tools enabled. The model may return `choices[].message.tool_calls`."
                    },
                    "response": []
                },
                {
                    "name": "JSON mode (response_format)",
                    "request": {
                        "method": "POST",
                        "header": [
                            { "key": "Content-Type", "value": "application/json" },
                            { "key": "Authorization", "value": "Bearer {{api_key}}" }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"model\": \"assigned-by-key\",\n    \"messages\": [\n        { \"role\": \"user\", \"content\": \"Return a JSON object with keys name and city for a fictional person.\" }\n    ],\n    \"response_format\": { \"type\": \"json_object\" }\n}"
                        },
                        "url": {
                            "raw": "{{base_url}}/api/v1/chat/completions",
                            "host": [ "{{base_url}}" ],
                            "path": [ "api", "v1", "chat", "completions" ]
                        },
                        "description": "Forces JSON output. Keys configured with Force JSON Response always request JSON regardless of this field."
                    },
                    "response": []
                }
            ]
        },
        {
            "name": "Ollama-Native",
            "description": "Endpoint: POST {{base_url}}/api/v1/chat.php — returns the native Ollama /api/chat response shape (NDJSON when streaming).",
            "item": [
                {
                    "name": "Chat (non-stream)",
                    "request": {
                        "method": "POST",
                        "header": [
                            { "key": "Content-Type", "value": "application/json" },
                            { "key": "Authorization", "value": "Bearer {{api_key}}" }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"model\": \"assigned-by-key\",\n    \"messages\": [\n        { \"role\": \"user\", \"content\": \"Why is the sky blue?\" }\n    ],\n    \"stream\": false\n}"
                        },
                        "url": {
                            "raw": "{{base_url}}/api/v1/chat.php",
                            "host": [ "{{base_url}}" ],
                            "path": [ "api", "v1", "chat.php" ]
                        },
                        "description": "Native Ollama chat. Returns a single JSON object with message.content, done, and token counts (prompt_eval_count / eval_count)."
                    },
                    "response": []
                },
                {
                    "name": "Chat (streaming NDJSON)",
                    "request": {
                        "method": "POST",
                        "header": [
                            { "key": "Content-Type", "value": "application/json" },
                            { "key": "Authorization", "value": "Bearer {{api_key}}" }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"model\": \"assigned-by-key\",\n    \"messages\": [\n        { \"role\": \"user\", \"content\": \"Tell me a short story.\" }\n    ],\n    \"stream\": true\n}"
                        },
                        "url": {
                            "raw": "{{base_url}}/api/v1/chat.php",
                            "host": [ "{{base_url}}" ],
                            "path": [ "api", "v1", "chat.php" ]
                        },
                        "description": "Newline-delimited JSON (application/x-ndjson). Each line is an Ollama chunk; the final line has done=true with token counts."
                    },
                    "response": []
                }
            ]
        }
    ]
}
