Skip to content

Instantly share code, notes, and snippets.

@ncouture
Created September 4, 2025 07:20
Show Gist options
  • Select an option

  • Save ncouture/a97fce3ff82471d62a72fd81d6d8664a to your computer and use it in GitHub Desktop.

Select an option

Save ncouture/a97fce3ff82471d62a72fd81d6d8664a to your computer and use it in GitHub Desktop.
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:11434/v1", # Local Ollama API
api_key="ollama" # Dummy key
)
response = client.chat.completions.create(
model="gpt-oss:20b",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain what a black hole is?"}
]
)
print(response.choices[0].message.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment