Instructions to use openai/gpt-oss-120b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openai/gpt-oss-120b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openai/gpt-oss-120b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openai/gpt-oss-120b") model = AutoModelForCausalLM.from_pretrained("openai/gpt-oss-120b") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openai/gpt-oss-120b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openai/gpt-oss-120b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openai/gpt-oss-120b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/openai/gpt-oss-120b
- SGLang
How to use openai/gpt-oss-120b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "openai/gpt-oss-120b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openai/gpt-oss-120b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "openai/gpt-oss-120b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openai/gpt-oss-120b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use openai/gpt-oss-120b with Docker Model Runner:
docker model run hf.co/openai/gpt-oss-120b
[Discussion] gpt-oss-120b hangs indefinitely ("thinking...") when using YaRN rope scaling to extend context length
I found an interesting issue when trying to extend the context window for gpt-oss-120b using YaRN rope scaling. When I launch the server with the following command, the model becomes stuck at "thinking..." and never produces any output.
vllm serve openai/gpt-oss-120b
--host 0.0.0.0
--tensor-parallel-size 2
--no-disable-sliding-window
--rope-scaling '{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":131072}'
--max-model-len 524288
Expected Behavior:
The model should be able to process and generate output for longer context windows using YaRN scaling.
Actual Behavior:
The server shows "thinking..." indefinitely, with no response or error message.
Questions:
Is YaRN rope scaling officially supported in vLLM for gpt-oss-120b?
read config.json
I did read the config.json — I'm actually discussing whether the context length can be extended beyond what's specified (131072), given that the model uses YaRN. That’s the main point I’m trying to clarify.
I've had some really weird behavior like that when the template gets screwed up, or there's something off about the temperature, etc., parameters. And they've been subtle screwups.
That said, I haven't tried enabling yarn yet. When I run into weird issues like that (this model delivers the weirdest tokens sequences when it isn't configured just right) I usually try eliminating the large serving subsystems li one vLLM and build a small client that just does the one thing. I get that you're trying to do it in vLLM but proving that it can work from a tiny example would be my first step.
If you'd like to increase YaRN scaling further, you need to multiply the original scaling factor by your new scaling factor: https://huggingface.co/openai/gpt-oss-120b/blob/main/config.json#L75
wondering why this model is responding to my first questions, but after a second or third reply, it just hang.
using the 120b model with ollama on my mac studio and entered a context length of 16k.
suprisingly, if i enter a "?" after a blank bottomline, it starts to think about my last response.
as i can see in the acitivity monitor, the m4max gpu is fully used...
