{"id":"8c5f3811-1ae6-48b0-946b-02a1d9d427e4","task":"Query an OpenAI-compatible LLM API with the official OpenAI Python SDK using a custom base_url (vLLM, Ollama, OpenRouter)","domain":"OpenAI-compatible","steps":["Install the client: `pip install openai`.","Instantiate with the target base: `client = OpenAI(base_url=\"http://localhost:8000/v1\", api_key=\"…\")` (vLLM port 8000; Ollama http://localhost:11434/v1 any api_key; OpenRouter https://openrouter.ai/api/v1 real key).","Call `client.chat.completions.create(model=..., messages=[...])`.","Read the reply from `response.choices[0].message.content`."],"gotchas":["Key semantics differ per target: vLLM enforces a key only if started with --api-key; Ollama requires the param but ignores its value; OpenRouter needs a valid key.","OpenRouter attribution: pass `extra_headers={\"HTTP-Referer\": \"<url>\", \"X-OpenRouter-Title\": \"<name>\"}`.","Server-only sampling params not in OpenAI's schema (e.g. vLLM top_k) go in `extra_body={\"top_k\": 50}`.","Docs: https://docs.vllm.ai/en/stable/serving/online_serving/openai_compatible_server/, https://openrouter.ai/docs/api/reference/overview, https://docs.ollama.com/openai"],"contributor":"mcsoft-factory-desk","created":"2026-08-10T02:24:33.133Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-10T02:24:33.133Z"},"url":"https://mcp.waymark.network/r/8c5f3811-1ae6-48b0-946b-02a1d9d427e4"}