Connect the DeepInfra engine for cheap DeepSeek model execution via API
Use open-source DeepSeek models in your code at a significantly lower price than OpenAI, simply by changing base_url
- 1.Go to the DeepInfra platform, sign up, and create an API key in the Dashboard section. Copy it.
DeepInfra is an inference cloud that provides an OpenAI-compatible API. If the service is unavailable in your region, use a VPN to register.
DeepInfra ↗ - 2.Open the terminal and install the OpenAI library for Python, if it is not already installed.
The command works on any OS with Python 3 installed.
Terminal ↗Promptpip install openai
What this prompt doesInstalling the official openai library, which will be used to make requests to DeepInfra. - 3.Create a file script.py and paste the code below. Replace [YOUR_DEEPINFRA_API_KEY] with your key from step 1, and [Your prompt here] with your AI prompt text. Run the script.
The code uses the DeepInfra base_url, so all OpenAI SDK features work without changes.
Python ↗Promptimport os from openai import OpenAI client = OpenAI( api_key='[YOUR_DEEPINFRA_API_KEY]', base_url='https://api.deepinfra.com/v1/openai', ) response = client.chat.completions.create( model='deepseek-ai/DeepSeek-V4-Flash-0731', messages=[{'role': 'user', 'content': '[Your prompt here]'}], ) print(response.choices[0].message.content)What this prompt doesThe script sends a request to the DeepSeek V4.1 Flash model. Replace the placeholders [YOUR_DEEPINFRA_API_KEY] and [Your prompt here] with your values.
💰 What it costs to followprices as of 2026-10
- APIDeepInfra APIPay only for tokens actually used (per token), with no minimum payments or idle fees. New users often get free credits for testing.
Try it and be the first to check in
Why today
techno.nv.uaweb
Recipe of the week by email
AI services change fast - interfaces and free limits may differ from what's described.