Running DeepSeek R1 via Together AI: Fastest Hosted Reasoning Model API

Updated
8 min read
Running DeepSeek R1 via Together AI: Fastest Hosted Reasoning Model API
TL;DR

Together AI hosts DeepSeek R1 671B on serverless infrastructure with streaming thinking tokens, OpenAI-compatible SDK, and sub-5-second TTFT - at $3/1M input tokens with no cold starts.

Why Together AI for DeepSeek R1?

DeepSeek offers its own API for R1 at $0.55/1M input tokens - cheaper than Together AI's $3/1M. But there are practical reasons to prefer Together:

  1. Reliability - DeepSeek's API has experienced outages and rate limiting during peak demand. Together AI runs on dedicated US-based infrastructure with SLA guarantees.
  2. Latency - Together AI has lower TTFT for US-based users (no cross-Pacific routing)
  3. Compliance - data processed via Together AI stays in the US, relevant for regulated industries
  4. No geoblocking - some enterprise networks block Chinese IP ranges

For teams where $3 vs $0.55 per million tokens is a meaningful budget concern, running R1 through DeepSeek direct or self-hosting makes sense. For most product teams, the reliability premium is worth it.

Setting Up Together AI

python
from together import Together

client = Together(api_key=os.environ["TOGETHER_API_KEY"])

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-R1",
    messages=[
        {
            "role": "user",
            "content": "Solve this step by step: If 5 workers can build a wall in 8 days, how many days would 10 workers take to build 3 such walls?",
        }
    ],
    stream=True,
)

for chunk in response:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Streaming Thinking Tokens

DeepSeek R1's "thinking" process - where it reasons through a problem before giving a final answer - can be streamed in real time. This allows you to show users a "thinking..." indicator while the model works, then display the final answer:

python
thinking_buffer = []
answer_buffer = []
in_thinking = False

for chunk in client.chat.completions.create(
    model="deepseek-ai/DeepSeek-R1",
    messages=[{"role": "user", "content": "Prove that the square root of 2 is irrational."}],
    stream=True,
):
    content = chunk.choices[0].delta.content or ""

    if "<think>" in content:
        in_thinking = True
    elif "</think>" in content:
        in_thinking = False
    elif in_thinking:
        thinking_buffer.append(content)
        print(f"[thinking] {content}", end="", flush=True)
    else:
        answer_buffer.append(content)
        print(content, end="", flush=True)

print("\n\nFinal answer:", "".join(answer_buffer))

Parallel Requests for Batch Processing

Together AI's serverless infrastructure handles parallel requests without rate limiting degradation. For batch reasoning tasks:

python
import asyncio
from together import AsyncTogether

async def reason(client: AsyncTogether, problem: str) -> str:
    response = await client.chat.completions.create(
        model="deepseek-ai/DeepSeek-R1",
        messages=[{"role": "user", "content": problem}],
    )
    return response.choices[0].message.content

async def batch_reason(problems: list[str]) -> list[str]:
    client = AsyncTogether(api_key=os.environ["TOGETHER_API_KEY"])
    tasks = [reason(client, p) for p in problems]
    return await asyncio.gather(*tasks)

results = asyncio.run(batch_reason(["Problem 1...", "Problem 2...", "Problem 3..."]))

Distilled R1 Variants for Lower Cost

Together AI also hosts the distilled R1 variants, which are much smaller but retain much of the reasoning quality:

Click any column to sort
4 rows
DeepSeek-R1671B$3.00/1MBaseline
DeepSeek-R1-Distill-Llama-70B70B$0.88/1M~90% quality
DeepSeek-R1-Distill-Qwen-32B32B$0.27/1M~85% quality
DeepSeek-R1-Distill-Qwen-7B7B$0.20/1M~75% quality

For most math and coding reasoning tasks, the 70B distill performs within 10% of the full 671B model at less than one-third the price. Start with the 70B distill and only escalate to the full model for problems that require it.

#deepseek-r1#together-ai#reasoning#api#cost

One AI engineering post, weekly

LLM benchmarks, prompt techniques, and token-cost breakdowns, delivered to your inbox.

What should we test or explain next?

Comments

Have a question or something to add? Sign in to join the discussion.

Mahmudul Haque Qudrati — CEO & ML Engineer at Pristren

Mahmudul Haque Qudrati

CEO & ML Engineer

Software architect, full-stack engineer, and machine learning practitioner. Founder & CEO of Pristren, CTO at Venture Kick-backed PIN Sport Application GmbH (Basel, Switzerland), Software Development Lead at DailyFrame GmbH (building Dimetra patient transport software), and creator of Zlyqor. Focused on custom workflow automation, scalable web and mobile applications, and production AI/ML systems.