Playground
Llama 3.3 70B Turbo
▾
Chat
Completions
Vision
JSON
system
You are a helpful AI assistant. Provide clear, accurate, and concise responses.
user
Write a Python function that computes the n-th Fibonacci number using memoization.
assistant
Here's a Python function using memoization to efficiently compute the n-th Fibonacci number:
def fib(n, memo={}):
if n in memo:
return memo[n]
if n <= 1:
return n
memo[n] = fib(n - 1) + fib(n - 2)
return memo[n]
This runs in O(n) time and O(n) space. The dictionary persists across calls, so repeated invocations are even faster.
cURL
Python
TypeScript
Endpoint
# Via Together AI Inference API
curl -X POST https://api.together.xyz/v1/chat/completions \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/Llama-3.3-70B-Instruct-Turbo",
"messages": [{"role":"user","content":"Hello"}],
"temperature": 0.7,
"max_tokens": 512,
"top_p": 0.9
}'
curl -X POST https://api.together.xyz/v1/chat/completions \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/Llama-3.3-70B-Instruct-Turbo",
"messages": [{"role":"user","content":"Hello"}],
"temperature": 0.7,
"max_tokens": 512,
"top_p": 0.9
}'