Does OpenAI charge for both prompt and completion?

Hi everyone, I had a simple question. Does OpenAI only charge for the number of tokens generated in the completion, or do they charge for both the number of tokens used in prompt and generated in the completion? Please answer if anybody knows. Thanks.

1 Like

Both prompt and completion. Same price per token

1 Like

No, not the same for most models! Usually the prompt tokens cost half of the completion tokens.
The exception is gpt-3.5-turbo (ChatGPT), where the price is the same.

My recent notes on that:

OPENAI_PRICING_USD_PER_1K_TOKENS = {
    'prompt': {
        'gpt-3.5-turbo': 0.002,
        'gpt-4-32k': 0.06,
        'gpt-4': 0.03,
    },
    'completion': {
        "gpt-3.5-turbo": 0.002,
        'gpt-4-32k': 0.12,
        'gpt-4': 0.06,
    }
}
1 Like

Thanks for this clarification on the charges for separate input and output tokens.