---
title: "Using Text Completion Format - with Completion()"
url: "/docs/tutorials/text_completion"
canonical_url: "https://docs.litellm.ai/docs/tutorials/text_completion"
type: "docs"
last_updated: "2026-11-03"
summary: "If your prefer interfacing with the OpenAI Text Completion format this tutorial covers how to use LiteLLM in this format"
related:
  - "/docs/tutorials/first_playground"
  - "/docs/tutorials/mock_completion"
---
# Using Text Completion Format - with Completion()

> Index of all LiteLLM docs: https://docs.litellm.ai/llms.txt


If your prefer interfacing with the OpenAI Text Completion format this tutorial covers how to use LiteLLM in this format
```python keep-model-ids
from openai import OpenAI

client = OpenAI()
response = client.completions.create(
    model="gpt-5.4-mini",
    prompt='Write a tagline for a traditional bavarian tavern',
    temperature=0,
    max_tokens=100)
```

## Using LiteLLM in the Text Completion format
### With gpt-5.4-mini
```python keep-model-ids
from litellm import text_completion
response = text_completion(
    model="gpt-5.4-mini",
    prompt='Write a tagline for a traditional bavarian tavern',
    temperature=0,
    max_tokens=100)
```

### With the OpenAI completions endpoint
This sends the prompt to OpenAI's legacy `/v1/completions` endpoint as is. See [OpenAI (Text Completion)](../providers/text_completion_openai.md) for which models still answer there.

```python keep-model-ids
response = text_completion(
    model="text-completion-openai/gpt-5.4-mini",
    prompt='Write a tagline for a traditional bavarian tavern',
    temperature=0,
    max_tokens=100)
```

### With an open model on Together AI
```python
response = text_completion(
    model="together_ai/openai/gpt-oss-120b",
    prompt='Write a tagline for a traditional bavarian tavern',
    temperature=0,
    max_tokens=100)
```

## Related pages

- [Create your first LLM playground](https://docs.litellm.ai/docs/tutorials/first_playground.md)
- [Mock Completion Responses - Save Testing Costs](https://docs.litellm.ai/docs/tutorials/mock_completion.md)
